Package dev.oumaimaa.kawaiiapi.colors
Class ColorTranslator
java.lang.Object
dev.oumaimaa.kawaiiapi.colors.ColorTranslator
Modern utility class for translating color codes in strings to Minecraft-compatible formats.
Supports legacy color codes (&), hex colors (invalid input: '&#'RRGGBB), and MiniMessage format.
Uses Adventure API exclusively for maximum compatibility with Paper 1.21+.
- Version:
- 1.0
- Author:
- KawaiiDevelopment
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder class for creating complex colored text using method chaining. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringcomponentToLegacy(@NotNull net.kyori.adventure.text.Component component) Converts a Component back to a legacy color code string.static @NotNull StringcomponentToPlain(@NotNull net.kyori.adventure.text.Component component) Converts a Component to plain text without any formatting.static @NotNull StringminiMessageToLegacy(@NotNull String miniMessage) Converts MiniMessage format to legacy color codes.static @NotNull StringstripColors(@NotNull String text) Strips all color codes and formatting from a string.static @NotNull StringtranslateColorCodes(@NotNull String text) Translates color codes and returns a legacy formatted string.static @NotNull net.kyori.adventure.text.ComponenttranslateMiniMessage(@NotNull String text) Translates MiniMessage format to Adventure Component.static @NotNull net.kyori.adventure.text.ComponenttranslateToComponent(@NotNull String text) Translates color codes in a string using legacy format (&) and hex colors (invalid input: '&#'RRGGBB).
-
Method Details
-
translateToComponent
@NotNull public static @NotNull net.kyori.adventure.text.Component translateToComponent(@NotNull @NotNull String text) Translates color codes in a string using legacy format (&) and hex colors (invalid input: '&#'RRGGBB). Returns an Adventure Component for modern Paper usage.- Parameters:
text- The string containing color codes- Returns:
- A Component with colors and formatting applied
-
translateColorCodes
Translates color codes and returns a legacy formatted string. Useful for compatibility with older APIs that require String format.- Parameters:
text- The string containing color codes- Returns:
- A string with Minecraft color codes (ยง) applied
-
translateMiniMessage
@NotNull public static @NotNull net.kyori.adventure.text.Component translateMiniMessage(@NotNull @NotNull String text) Translates MiniMessage format to Adventure Component. Supports advanced formatting like gradients, hover events, click events, etc.- Parameters:
text- The MiniMessage formatted text- Returns:
- A Component with formatting applied
-
stripColors
-
componentToLegacy
@NotNull public static @NotNull String componentToLegacy(@NotNull @NotNull net.kyori.adventure.text.Component component) Converts a Component back to a legacy color code string.- Parameters:
component- The component to serialize- Returns:
- Legacy formatted string
-
componentToPlain
@NotNull public static @NotNull String componentToPlain(@NotNull @NotNull net.kyori.adventure.text.Component component) Converts a Component to plain text without any formatting.- Parameters:
component- The component to serialize- Returns:
- Plain text representation
-
miniMessageToLegacy
-