Package valorless.valorlessutils.color
Class McToAnsi
java.lang.Object
valorless.valorlessutils.color.McToAnsi
Utility for converting Minecraft color codes to ANSI escape sequences.
Supported inputs include legacy codes such as §a and hex color
sequences such as §x§R§R§G§G§B§B. The returned text always ends
with an ANSI reset sequence.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
McToAnsi
public McToAnsi()
-
-
Method Details
-
convert
Converts Minecraft formatting codes in a string to ANSI escape sequences.Conversion happens in two passes:
- Hex codes in the format
§x§R§R§G§G§B§Bare converted to\033[38;2;R;G;Bm. - Legacy color/reset codes (
§0-§9,§a-§f,§r) are converted usingCOLOR_MAP.
\033[0mto ensure color reset.- Parameters:
text- the Minecraft-formatted input string- Returns:
- ANSI-formatted text ending with a reset sequence
- Hex codes in the format
-