Question How to make color codes work?

Durov

New member
Mar 29, 2022
3
0
1
Hello everyone, I am writing my plugin for the chat implementation, how can I implement the use of the symbol & + color code

At the moment I have a line

if(p.hasPermission("color.chat")){ e.getMessage().replaceAll("&", "§"); }

However, the plugin does not work in operation.
Note: I want to make the player when he writes a message, for example &c Hello and the color symbols disappear and the message is red.
 
Solution
You need to set the message contents with setMessage after you replace the &:
Java:
e.setMessage(e.getMessage().replaceAll("&", "§"));