Parse Essentials RGB Hexcode nickname colors

This commit is contained in:
Jeff P 2021-07-28 21:15:33 -04:00 committed by GitHub
parent e0626c7cac
commit 23a0419c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -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("<span style=\'color:#" + hex + "\'>"); // Substitute with hexcode
i = i + 12; //move past hex codes
}
}
break;
}
}
else if (c == '&') { // Essentials color code?
i++; // Move past it