So for my current Bukkit (Minecraft) plugin, I have to work with ItemStacks' names. I get these names by doing
item.getItemMeta().getDisplayName();
.
Since the Items represent players, they have the players' names. But unfortunately, there are also color codes. The result I get when receiving the name then is something like "§7Baustein", where "§7" is the color code and "Baustein" is the player's name.
Now the color code can also be "§a" or "§3" or anything like that. To get only the player's name, I have to remove that color code out of the string I get.
I know how to remove the "§" since it's always the same: string.replaceAll("§", "");
. But then there's as well this hexadecimal digit behind it, and I don't know what specific digit it is.
Rather than checking all possibilities, is there a way to kind of replaceAll("§" + the digit behind, "");
?
I've checked out questions like this one, but either I did not really get it, or it's just not including my answer.
Maybe someone can help me?