Class ConsoleColorSerializer

java.lang.Object
dev.ua.theroer.magicutils.logger.ConsoleColorSerializer

public final class ConsoleColorSerializer extends Object
Serializes log Components for console output, preferring ANSI colors when the adventure ANSI serializer is on the classpath and falling back to plain text otherwise.

The ANSI serializer is loaded reflectively so platforms without it (lean shaded jars, older Bungee/Fabric builds) still work — they simply receive uncolored text.

  • Method Details

    • serialize

      public static String serialize(net.kyori.adventure.text.Component component)
      Serializes a component to ANSI-colored text when possible, otherwise to plain text.
      Parameters:
      component - component to serialize, may be null
      Returns:
      rendered string, or empty string when component is null
    • ansiAvailable

      public static boolean ansiAvailable()
      Checks if ANSI color serialization is available in the current environment.
      Returns:
      true when the ANSI serializer was successfully loaded and colors will be emitted