Discussion in 'Spigot Plugin Development' started by Torciv, Jun 25, 2018.

  1. Hi I am trying to make a custom Help with hover and click events.

    The problem is That I just only want to have a certain hover event for the first part of the command.



    So basically I want the hover text and the click event to only the first part of the command
    because Arguments and HelpText will have its own personal hover and click stuff...

    So it should only be displayed and click for /test debug, /test one, /test two three, /test two four

    Here is my current code:
    Code (Text):
    ArrayList<ComponentBuilder> helpList2 = new ArrayList<>();
    String baseCmd = "/" + command + " " + cmd.cmd();
                        String onlyArgs = (!cmd.args().equals("") ? " " + cmd.args() : "");
                        String baseCmdWithArgs = baseCmd + onlyArgs;
                        String desc = ": " + ChatColor.WHITE +(specific ? (cmd.longhelp().equals("") ? : cmd.longhelp()) :;

                        ComponentBuilder b = new ComponentBuilder(baseCmd)
                                .event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, baseCmdWithArgs))
                                .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(baseCmdWithArgs)
                                .append(ChatColor.GRAY + "Click para pegar el comando \n"
                                        + ChatColor.GRAY + "en el chat.").create()))
                                .append(onlyArgs + desc);


    Where i Send the message
    Code (Text):

    if(sender instanceof Player){
        Player player = (Player) sender;
        player.spigot().sendMessage(helpList2.get(j + page * perPage).create());

  2. Code (Text):
    .append(onlyArgs + desc, ComponentBuilder.FormatRetention.NONE);
    • Agree Agree x 1
  3. That worked very well :) Thank you.
    Also just a quick question.

    Why do I need to put the color each time I do a \n in the hover?

    Code (Text):
                                .append(ChatColor.GRAY + "Click para pegar el comando \n"
                                        + ChatColor.GRAY + "en el chat.").create()))
    Isn't any other way so that I dont need to do it?

    Thanks for your help.
  4. No way as I know. It's how the Minecraft color codes works.