🎨Color Utility
ColorUtil
is a utility class meant for manipulating strings to incorporate color codes. It includes methods to parse and translate both traditional Minecraft color codes and hex color codes.
Method: translate(String input)
translate(String input)
This method translates a given string containing basic Minecraft color codes and hex color codes into a format that Minecraft can understand and display.
Parameters:
input
: A string containing color codes. Basic color codes are prefixed with&
, and hex color codes are enclosed in square brackets, like&[FFFFFF]
.
Functionality:
The method uses a regular expression pattern to find and process hex color codes in the input string.
Each found hex color code is converted to a format that Minecraft's
ChatColor
class can interpret.After processing hex codes, the method translates the rest of the basic color codes using Bukkit's
ChatColor.translateAlternateColorCodes
method.
Example Usage:
Last updated