From 23a0419c7de9593546def18c743d95b1b2b6b840 Mon Sep 17 00:00:00 2001 From: Jeff P Date: Wed, 28 Jul 2021 21:15:33 -0400 Subject: [PATCH] Parse Essentials RGB Hexcode nickname colors --- .../src/main/java/org/dynmap/Client.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/DynmapCore/src/main/java/org/dynmap/Client.java b/DynmapCore/src/main/java/org/dynmap/Client.java index e48f06bf..73efc257 100644 --- a/DynmapCore/src/main/java/org/dynmap/Client.java +++ b/DynmapCore/src/main/java/org/dynmap/Client.java @@ -226,6 +226,26 @@ public class Client { break; } } + else if (c == 'x') { // Essentials nickname hexcode format + if (i + 12 <= cnt){ // Check if string is at least long enough to be valid hexcode + if (s.charAt(i+1) == s.charAt(i+3) && + s.charAt(i+1) == s.charAt(i+5) && + s.charAt(i+1) == s.charAt(i+7) && + s.charAt(i+1) == s.charAt(i+9) && + s.charAt(i+1) == s.charAt(i+11) && // Check if there are enough ยง in a row + s.charAt(i+1) == '\u00A7'){ + StringBuilder hex = new StringBuilder().append(s.charAt(i+2)) + .append(s.charAt(i+4)) + .append(s.charAt(i+6)) + .append(s.charAt(i+8)) + .append(s.charAt(i+10)) + .append(s.charAt(i+12)); // Build hexcode string + sb.append(""); // Substitute with hexcode + i = i + 12; //move past hex codes + } + } + break; + } } else if (c == '&') { // Essentials color code? i++; // Move past it