It is possible to have clickable chat messages. To achieve that you create a custom ChatStye and add a ClickEvent to it. After that this ChatStyle can be applied to an IChatComponent. The ClickEvent allows you to choose an Action from an predefined Enum. The available Actions are: OPEN_URL, OPEN_FILE, RUN_COMMAND, TWITCH_USER_INFO, SUGGEST_COMMAND and CHANGE_PAGE. In my case I want to define custom click behavior. I tried overriding ClickEvent.getAction() but that doesn't seem to work...
Here is my code so far:
IChatComponent comp = new ChatComponentText("Text");
ChatStyle style = new ChatStyle().setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "") {
@Override
public Action getAction() {
//custom behavior
return Action.RUN_COMMAND;
}
});
comp.setChatStyle(style);