Question Replacement for ChatColor.translateAlternateColorCodes

ikonodim

New member
Jul 18, 2024
4
0
1
I'm looking for a suitable replacement for this snippet of my code as it is deprecated:
Java:
private String translateColorCodes(String text) {
    return ChatColor.translateAlternateColorCodes('&', text);
}
I am using 1.20.6
 
Version Output
1.20.6-148-ver
Api Version 1.20.6-R0.1-Snapshot
Solution
It's 2024, so you should be using components instead of the legacy color code stuff (which Mojang replaced for chat in 2013).

If this is based on configuration, migrate to use MiniMessage, which allows proper component creation (including all the fun stuff like fonts, translation, clickable, hoverable. If this is in-plugin stuff, either use MiniMessage still or just build Components properly.

mbaxter

Cat Wrangler
Staff member
Dec 14, 2021
67
20
10
8
over there
It's 2024, so you should be using components instead of the legacy color code stuff (which Mojang replaced for chat in 2013).

If this is based on configuration, migrate to use MiniMessage, which allows proper component creation (including all the fun stuff like fonts, translation, clickable, hoverable. If this is in-plugin stuff, either use MiniMessage still or just build Components properly.
 
  • Like
Reactions: ikonodim
Solution