Illegal characters in chat

Discussion in 'Plugin Development' started by Ahrigumi, Jul 8, 2018.

  1. Online

    Ahrigumi

    So.. this is the code of a spigot ChatComponent.
    Code:
        public void Solicitud(Player p1, Player p2) {
            TextComponent message = new TextComponent( ChatColor.GOLD + "test");
            TextComponent si = new TextComponent("[SI]");
            si.setColor(ChatColor.DARK_GREEN);
            si.setBold(true);
            si.addExtra("");
            si.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/test add " + p1.getDisplayName()));
            TextComponent no = new TextComponent(" [NO]");
            no.setColor(ChatColor.RED);
            no.setBold(true);
            no.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/test deny" + p1.getDisplayName()));
            p2.spigot().sendMessage(message, si, no); 
        }
    
    And the problem is, When i do the click in the message json (/test add or /test deny) the server kick to me and appear in the chat "Illegal characters in chat". Dont really know why appear, but i can fix that removing "getDisplayName" from "blabla.(ClickEvent.Action.RUN_COMMAND, "/test deny" + p1.getDisplayName());
     
  2. Offline

    MightyOne

    What are the players' display names?
     
  3. Offline

    Iran

    Well, you first need a space after /test deny " " p1.getDisplayName().

    Also can you send a gif or a picture of trying it so we get the full picture?
     
  4. Online

    Tabuu_

    Remove the '/' at the beginning of your command.
     

Share This Page