I am trying to output a players nickname and username in one string but it seems that whatever formatting the nickname has is overriding the formatting I add. For example, if the players nickname is red in-game, it appears as red when I print out the string, regardless of the ChatColor function I use. How can I force the ChatColor I specify to the one color the text appears as? Here is the bit of code in question: Code (Text): usernameNickname = "" + ChatColor.WHITE + ess.getUser(p).getNickname().toString() + ChatColor.WHITE + " - " + ess.getUser(p).getName().toString(); Maybe get the nickname as just the nickname string, without any extra formatting?
chatcolor.reset is what youre looking for. this will reset the formatting from text before it so it does not apply to text after it.
getNickname() might come with a chat color embedded in it. You can try Code (Java): usernameNickname = "" + ChatColor.WHITE + ChatColor.stripColor(ess.getUser(p).getNickname().toString()) + ChatColor.WHITE + " - " + ess.getUser(p).getName().toString(); or a cleaned up version: Code (Java): usernameNickname = "" + ChatColor.stripColor(ess.getUser(p).getNickname() + " - " + ess.getUser(p).getName());
That did the trick, thank you. It was frustrating me to no end that I couldn't get the formatting to work correctly.