Jump to content

Recommended Posts

Posted

I'm making a update checker that tells the user in the chat when theres a new version of the mod. What I what is a link to my download page, and I know I can do this to make a link:

 

ChatStyle link = new ChatStyle();

link.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://minecraft.curseforge.com/projects/dimensionalcore/files"));
link.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.AQUA + "Download the latest version of DimensionalCore")));
link.setColor(EnumChatFormatting.BLUE);

event.player.addChatMessage(new ChatComponentText("[Download]" + EnumChatFormatting.RESET + " A new version of DimensionalCore is available:").setChatStyle(link));

 

But I only want the link to be on the [Download] part not the whole thing. How to make the link only work on the [Download] part?

Posted

I changed my code to this:

 

ChatStyle link = new ChatStyle();

link.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://minecraft.curseforge.com/projects/dimensionalcore/files"));
link.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.AQUA + "Download the latest version of DimensionalCore")));
link.setColor(EnumChatFormatting.BLUE);

IChatComponent button = new ChatComponentText("[Download]").setChatStyle(link);
IChatComponent text = new ChatComponentText(EnumChatFormatting.RESET + " A new version of DimensionalCore is available:").setChatStyle(new ChatStyle());

event.player.addChatMessage(button.appendSibling(text));

 

But it still does the same thing. What am I doing wrong?

Posted

How would I do that? I tried:

 

ChatStyle link = new ChatStyle();
ChatStyle nolink = new ChatStyle();

nolink.setChatClickEvent(null));
nolink.setChatHoverEvent(null)));

link.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://minecraft.curseforge.com/projects/dimensionalcore/files"));
link.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.AQUA + "Download the latest version of DimensionalCore")));
link.setColor(EnumChatFormatting.BLUE);

IChatComponent button = new ChatComponentText("[Download]").setChatStyle(link);
IChatComponent text = new ChatComponentText(EnumChatFormatting.RESET + " A new version of DimensionalCore is available:").setChatStyle(nolink);

 

And:

 

ChatStyle link = new ChatStyle();
ChatStyle nolink = new ChatStyle();

nolink.setParentStyle(null);

link.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://minecraft.curseforge.com/projects/dimensionalcore/files"));
link.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.AQUA + "Download the latest version of DimensionalCore")));
link.setColor(EnumChatFormatting.BLUE);

IChatComponent button = new ChatComponentText("[Download]").setChatStyle(link);
IChatComponent text = new ChatComponentText(EnumChatFormatting.RESET + " A new version of DimensionalCore is available:").setChatStyle(nolink);

 

 

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.