How can i do this?

Discussion in 'Plugin Development' started by user_91277742, Jan 27, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    user_91277742

    Hello there again!
    So.. i will explain what i want to do...

    Actually, Im using a method to print on chat 2 lines with a message json (Using TextComponent).
    The message to replace and use is this:

    Code:
    announced: "The class of %class% will start soon."
    clickHere: "click here!"
    announced-click: %click% to join in the queue
    
    And the code is this

    Code:
        public void announce(Player p, String class) {
            String clickHere = this.mensajesConfig.getString("clickHere");
            String clickAnuncio = this.mensajesConfig.getString("announced-click");
            String newAnuncio = clickAnuncio.replace("%click%", clickHere);
            String announced = this.mensajesConfig.getString("announced");
            String newAnnounced = announced.replace("%class%", class);
            TextComponent mensajeInicial = new TextComponent(newAnnounced);
            mensajeInicial.setColor(ChatColor.GREEN);
            TextComponent click = new TextComponent(newAnuncio);
            click.setColor(ChatColor.GOLD);
            click.setBold(true);
            click.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/class join " + class));
            p.spigot().sendMessage(mensajeInicial);
            p.spigot().sendMessage(click);
        }
    
    Actually using this code, I have this result .

    [​IMG]
    (I can execute the command clicking in all the line and not just on click here)

    So, basically i want to separate the phrase "to join in the queue" from "click here!" to just let the properties to click to the words "click here" . (Sorry, i know is a little confused to explain)

    The problem is , when i get the phrase "%click% to join in the queue" and i replace the value %click% for another string, all the phrase get all the properties of the textcomponent. So.. what can i do with "%click% to join in the queue" , to replace click , put on textcomponent, add differents properties and at the same time be the same phrase to print on chat?

    Thanks :D

    Edit; I tried to put "click-here" and "to join in the queue" on differents textcomponent and connecting both in p.spigot().sendMessage(blablabla); , but appear the message repating twice the "click-here"
     
Thread Status:
Not open for further replies.

Share This Page