java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.text.HexSupport

public final class HexSupport extends Object
Version gate + hex encoder for chat/item colour. Probes reflectively for the 1.16-only net.md_5.bungee.api.ChatColor.of(String) method (the class exists on 1.8 too, as a plain enum — so probe the method, not the class) and caches the result once at class load.

On 1.16+ a hex colour is encoded as the native §x§r§r§g§g§b§b wire sequence; on older servers it is downsampled to the nearest of the 16 legacy colours, so the same template renders acceptably everywhere from 1.8.8 upward.

  • Field Details

    • NATIVE_HEX

      public static final boolean NATIVE_HEX
      true on 1.16+ where native 24-bit chat colour renders. Resolved once at class load.
  • Method Details

    • hex

      public static String hex(String hexColor)
      Encode for the running server version.
    • encode

      public static String encode(String hexColor, boolean nativeHex)
      Encode for an explicit version capability (test seam / cross-version rendering).
    • toHexSequence

      public static String toHexSequence(String hex)
      "#1a2b3c"/"1a2b3c" -> "§x§1§a§2§b§3§c" (1.16+ native wire format).
    • nearestLegacy

      public static String nearestLegacy(String hex)
      "#rrggbb"/"rrggbb" -> nearest legacy "§<code>" by unweighted RGB distance.