Skip to content

ChatParser broken since ChatColor is no longer enum #13

@PrinceBunBun981

Description

@PrinceBunBun981

Since ChatColor is no longer an anum using formatting codes like &a, &b, &c, etc. Here's the new area in the class that I've been using that seems to work with it when using Strings:

// In ChatParser.java
ChatColor color = ChatColor.getByChar(group_color.charAt(0));
if (color != null) {
    switch (color.getName().toUpperCase()) {
        case "MAGIC":
            current.setObfuscated(true);
            break;
        case "BOLD":
            current.setBold(true);
            break;
        case "STRIKETHROUGH":
            current.setStrikethrough(true);
            break;
        case "UNDERLINE":
            current.setUnderlined(true);
            break;
        case "ITALIC":
            current.setItalic(true);
            break;
        case "RESET":
            color = ChatColor.WHITE;
        default:
            current = new TextComponent();
            current.setColor(color);
            current.setBold(forceBold > 0);
            current.setItalic(forceItalic > 0);
            current.setUnderlined(forceUnderlined > 0);
            current.setStrikethrough(forceStrikethrough > 0);
            if (!colorDeque.isEmpty()) {
                current.setColor(colorDeque.peek());
            }
            if (!clickEventDeque.isEmpty()) {
                current.setClickEvent(clickEventDeque.peek());
            }
            if (!hoverEventDeque.isEmpty()) {
                current.setHoverEvent(hoverEventDeque.peek());
            }
    }

    parsed = true;
}

As well as some depreciated code in the ChatParser:
ChatColor.values(),
hoverEventDeque.getLast().getValue(), and
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, components1);.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions