Posted March 26, 20196 yr 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; } Edited March 26, 20196 yr by nethersteel code wasn't correctly showing
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.