1.17.x Is there any way to add hex colours to item display names?

Discussion in 'Spigot Plugin Development' started by Xemor, Jun 26, 2021.

  1. Question in title
  2. SteelPhoenix


    Why wouldn't there be? Did you try it?
  3. Never tried it, but why would it not be possible? Simply search (for example on youtube) spigot [version] hex color codes, and boom:

    EDIT: I didn't tried it, but in my lib I have that:
    Code (Text):
    public static String translateHex(String version, String message){
                Matcher matcher = pattern.matcher(message);
                while (matcher.find()){
                    String color = message.substring(matcher.start(), matcher.end());
                    message = message.replace(color, ChatColor.of(color) + "");
                    matcher = pattern.matcher(message);
            return translateBasic(message);
    Your free to use if you want.
  4. I forgot about the ChatColor.of() method as I'm used to working with Adventure Components / BaseComponents.
  5. I think ChatColor.of() returns the nearest ChatColor of the hex code. But because you want to get the hex color as a custom color, you have to use encrypt or mine method.