I want to add color formats to my plugin (like essentials has colors in chat). For example, &6test
would become "test" in gold.
I almost added those colors, but I have a problem. It deletes the whole message and leaves the green test message. How do I add colors?
Right now I'm using this:
public void onPlayerChat(AsyncPlayerChatEvent chatevent){
for (String word : chatevent.getMessage().split(" ")){
word = word.replaceAll("&2", "§2test");
chatevent.setMessage(word);
if(SysMng.getConfig().getStringList("badwords").contains(word)){
if (!chatevent.getPlayer().hasPermission("bypassbadwords")){
chatevent.setCancelled(true);
chatevent.getPlayer().sendMessage(ChatColor.RED + "Dont use dirty or swear words!");
}
}
}
}
But, like I said, it deletes the whole message and leaves the green test message. This is caused by:
word = word.replaceAll("&2", "§2test");
chatevent.setMessage(word);
Ignore the "badwords" part, it is just to prevent people from using swear words. How do I fix this so that players could use colors codes in chat?