Color Player's Message

Discussion in 'Plugin Development' started by DogeDebugger, Jan 29, 2015.

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

    DogeDebugger

    I'm looking for the best way to color a player's message. I tried this but it doesnt work .-.

    Code:
        @EventHandler
        public void playerChat(AsyncPlayerChatEvent e){
                Player player = e.getPlayer();
                String name = player.getName();
                if(toggledred.contains(name)) {
                    e.setFormat(ChatColor.RED + e.getMessage());
                }
            }
     
  2. Offline

    teej107

    @DogeDebugger Are you sure toggledred contains your player name?
     
  3. Offline

    DogeDebugger

    Yes.
     
  4. Offline

    Konato_K

    @DogeDebugger If the name has colors in between it won't work

    Also why are you using setFormat wrongly?
     
  5. Offline

    DogeDebugger

    I couldnt figure out the method for making a player say something so i gave that a shot .-.
     
  6. Offline

    Protophite

    Code:
    @EventHandler
    public void onChat(AsyncPlayerChatEvent e){
        e.setMessage(ChatColor.RED + e.getMessage());
    }
    
    @DogeDebugger
     
  7. Offline

    DogeDebugger

    Thanks.
     
  8. Offline

    MordorKing78

  9. Offline

    1Rogue

    You should not be modifying the message for format reasons, if you want to change the format then use .setFormat:

    Code:java
    1. event.setFormat("%s: " + ChatColor.RED + "%s");
     
    Protophite likes this.
Thread Status:
Not open for further replies.

Share This Page