Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChatParser broken since ChatColor is no longer enum #13

Open
PrinceBunBun981 opened this issue May 5, 2021 · 0 comments
Open

ChatParser broken since ChatColor is no longer enum #13

PrinceBunBun981 opened this issue May 5, 2021 · 0 comments

Comments

@PrinceBunBun981
Copy link

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);.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant