HoverEvent SHOW_TEXT

Discussion in 'Spigot Plugin Development' started by iversen, May 7, 2015.

  1. Hey. I am having trouble making this work:
    Code (Text):
    LinkMessage.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(this.getConfig().getString("Voting1.HoverMessage")).create() ));
    I have no clue why it doesn't work... I just want "Voting1.VotingMessage" from the config to be a hover message for the message "LinkMessage" *from the config aswell*

    I might just mess up because I am trying to get rid of TextComponent so I can easier allow using color codes in the config with "translateAlternateColorCodes", but the setHoverEvent might still be a textcomponent?
    This is the message I want the hover text from the config to be displayed on:
    message.addExtra(LinkMessage);
    Thanks in advance :3


    This is the config:
    http://pastebin.com/ZPXVyqva
     
  2. To create a colored message using the old system you will have to translateAlternateColorCodes () with the string you wish to send. Then create the new message from that string with TextComponent#fromLegacyText (). Wrap that in a new ComponentBuilder and addEvent to add your hover event. In the hover event text you have to do a similar thing. Teanslate and then fromLegacyText. Then send the player the ComponentBuilder#create ()ed message.
     
    • Useful Useful x 1