Class LegacyColors

java.lang.Object
com.kamikazejam.kamicommon.util.LegacyColors

@Obsolete public class LegacyColors extends Object
A legacy color-code translator for Minecraft-style formatting codes.
Translates the alternate code character & into the legacy section sign (§) and optionally expands 1.16+ hex color codes of the form &#RRGGBB into the §x§R§R§G§G§B§B sequence used by legacy clients.
Notes:
- This API is marked @Obsolete. Prefer modern text/color APIs where possible.
- Basic legacy color/format codes supported: 0-9, a-f, k-o, r (case-insensitive), e.g. &a, &l, &r, etc.
- Hex color support requires either forceTranslateHex = true or BukkitAdapter.supportsHexCodes() to be true.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The legacy color code character (section sign), '§'.
    static final @NotNull Pattern
    Case-insensitive pattern that matches legacy color and format codes to strip.
    Matches:
    - §[0-9A-FK-OR] (single legacy codes), and
    - §x(§[0-9A-F0-9]){6} (expanded hex color sequences).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Replaces the legacy section sign § with the alternate color code character & in a single string.
    static String[]
    Replaces the legacy section sign § with & in each string of the provided array.
    static List<String>
    Replaces the legacy section sign § with & in each string of the provided list.
    static String
    Removes all legacy color and format codes from the provided string.
    Supports stripping single legacy codes and expanded hex sequences.
    static String
    t(String msg)
    Translates alternate color codes in a message from & to §.
    Hex colors of the form &#RRGGBB are translated only if supported by the runtime (BukkitAdapter.supportsHexCodes() is true).
    static List<String>
    t(String... msgs)
    Translates alternate color codes for an array of messages using t(String) behavior (hex translation only if supported).
    static String
    t(String msg, boolean forceTranslateHex)
    Translates alternate color codes in a message from & to § and, if enabled or supported, converts hex colors of the form &#RRGGBB into the legacy expanded §x§R§R§G§G§B§B sequence.
    static List<String>
    t(List<String> msgs)
    Translates alternate color codes for a list of messages using t(String) behavior (hex translation only if supported).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • COLOR_CHAR

      public static final char COLOR_CHAR
      The legacy color code character (section sign), '§'.
      See Also:
    • STRIP_COLOR_PATTERN

      @NotNull public static final @NotNull Pattern STRIP_COLOR_PATTERN
      Case-insensitive pattern that matches legacy color and format codes to strip.
      Matches:
      - §[0-9A-FK-OR] (single legacy codes), and
      - §x(§[0-9A-F0-9]){6} (expanded hex color sequences).
  • Constructor Details

    • LegacyColors

      public LegacyColors()
  • Method Details

    • t

      @Obsolete public static String t(String msg, boolean forceTranslateHex)
      Translates alternate color codes in a message from & to § and, if enabled or supported, converts hex colors of the form &#RRGGBB into the legacy expanded §x§R§R§G§G§B§B sequence.
      Parameters:
      msg - the input message (non-null expected)
      forceTranslateHex - if true, hex codes are translated regardless of BukkitAdapter.supportsHexCodes()
      Returns:
      the translated message with legacy codes applied
    • t

      @Obsolete public static String t(String msg)
      Translates alternate color codes in a message from & to §.
      Hex colors of the form &#RRGGBB are translated only if supported by the runtime (BukkitAdapter.supportsHexCodes() is true).
      Parameters:
      msg - the input message (non-null expected)
      Returns:
      the translated message with legacy codes applied
    • t

      @Obsolete public static List<String> t(List<String> msgs)
      Translates alternate color codes for a list of messages using t(String) behavior (hex translation only if supported).
      Parameters:
      msgs - list of input messages
      Returns:
      a new list containing translated messages
    • t

      @Obsolete public static List<String> t(String... msgs)
      Translates alternate color codes for an array of messages using t(String) behavior (hex translation only if supported).
      Parameters:
      msgs - array of input messages
      Returns:
      a new list containing translated messages
    • strip

      @Obsolete @Contract(value="null -> null; !null -> !null", pure=true) public static String strip(String s)
      Removes all legacy color and format codes from the provided string.
      Supports stripping single legacy codes and expanded hex sequences.
      Parameters:
      s - the input string, may be null
      Returns:
      the input without legacy color/format codes, or null if input is null
    • reverseT

      @Obsolete public static String reverseT(String s)
      Replaces the legacy section sign § with the alternate color code character & in a single string.
      Parameters:
      s - the input string
      Returns:
      the string with § replaced by &
    • reverseT

      @Obsolete public static List<String> reverseT(List<String> s)
      Replaces the legacy section sign § with & in each string of the provided list.
      Parameters:
      s - a list of strings to transform
      Returns:
      a new list with § replaced by & in each element
    • reverseT

      @Obsolete public static String[] reverseT(String[] s)
      Replaces the legacy section sign § with & in each string of the provided array.
      Parameters:
      s - an array of strings to transform
      Returns:
      a new array with § replaced by & in each element