Solved Problem with setting display name

Discussion in 'Plugin Development' started by davidclue, May 4, 2021.

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

    davidclue

    Hi, I am trying to set a players display name to simply have a team color by using
    Code:
    p.setDisplayName(ChatColor.BLUE+p.getDisplayName()+ChatColor.WHITE);
    This works and the player's name is in blue whenever they send a message in chat, however when I try to remove the color from the display name with
    Code:
    p.setDisplayName(ChatColor.RESET+p.getDisplayName());
    It does not work and the player still has the blue name, even when I do this instead
    Code:
    p.setDisplayName(ChatColor.WHITE+p.getDisplayName());
    It still gives the player a blue name when they type and yes I have verified that the code is running and the blue prefix is not running afterward. This is simply a problem with not being able to reset or change the color again after changing it once and I don't know how to fix it. I have also tried this
    Code:
    p.setDisplayName(ChatColor.RESET.toString()+ChatColor.WHITE+p.getDisplayName());
    If anybody knows a fix or another way around changing a player's name to have their team color please let me know. I also use teams for this and the prefix, suffix, and setColor methods do not affect the player names in chat.
     
  2. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page