Jump to content

clickevent open url not working


nethersteel

Recommended Posts

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 by nethersteel
code wasn't correctly showing
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.