Class HexSupport
java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.text.HexSupport
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final booleantrueon 1.16+ where native 24-bit chat colour renders. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncode for an explicit version capability (test seam / cross-version rendering).static StringEncode for the running server version.static StringnearestLegacy(String hex) "#rrggbb"/"rrggbb"-> nearest legacy"§<code>"by unweighted RGB distance.static StringtoHexSequence(String hex) "#1a2b3c"/"1a2b3c"->"§x§1§a§2§b§3§c"(1.16+ native wire format).
-
Field Details
-
NATIVE_HEX
public static final boolean NATIVE_HEXtrueon 1.16+ where native 24-bit chat colour renders. Resolved once at class load.
-
-
Method Details
-
hex
Encode for the running server version. -
encode
Encode for an explicit version capability (test seam / cross-version rendering). -
toHexSequence
"#1a2b3c"/"1a2b3c"->"§x§1§a§2§b§3§c"(1.16+ native wire format). -
nearestLegacy
"#rrggbb"/"rrggbb"-> nearest legacy"§<code>"by unweighted RGB distance.
-