I wrote the following code, now when I hover the chat message it does correctly display the correct link in the hover event but when I click it it does nothing, how do I fix this so it opens the link when clicked?
if (message.contains("https")) {
String[] split = message.split(" ");
int count = 0;
String link = null;
for (String string : split) {
if (string.contains("https")) {
link = string;
break;
}
}
newMessage = EnumChatFormatting.DARK_BLUE + prefix + EnumChatFormatting.RESET + "" + message;
ChatComponentText msgToSend = new ChatComponentText(newMessage);
if (link != null) {
msgToSend.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.RED + link)));
msgToSend.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
mc.thePlayer.addChatMessage(msgToSend);
}
break;
}