Class McToAnsi

java.lang.Object
valorless.valorlessutils.color.McToAnsi

public class McToAnsi extends Object
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 Details

    • McToAnsi

      public McToAnsi()
  • Method Details

    • convert

      public static String convert(String text)
      Converts Minecraft formatting codes in a string to ANSI escape sequences.

      Conversion happens in two passes:

      1. Hex codes in the format §x§R§R§G§G§B§B are converted to \033[38;2;R;G;Bm.
      2. Legacy color/reset codes (§0-§9, §a-§f, §r) are converted using COLOR_MAP.
      The returned string is suffixed with \033[0m to ensure color reset.

      Parameters:
      text - the Minecraft-formatted input string
      Returns:
      ANSI-formatted text ending with a reset sequence