Merge pull request #65 from KrystilizeNevaDies/master

Fix rgb byte overflow
This commit is contained in:
KrystilizeNevaDies 2020-11-05 06:43:17 -08:00 committed by GitHub
commit 3c3230ae1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -263,19 +263,9 @@ public class ChatColor {
code = codeName;
} else {
// RGB color
String redH = Integer.toHexString(red);
if (redH.length() == 1)
redH = "0" + redH;
int color = (red & 0xFF) << 16 | (green & 0xFF) << 8 | blue & 0xFF;
String greenH = Integer.toHexString(green);
if (greenH.length() == 1)
greenH = "0" + greenH;
String blueH = Integer.toHexString(blue);
if (blueH.length() == 1)
blueH = "0" + blueH;
code = redH + greenH + blueH;
code = "#"+Integer.toHexString(color);
}
return header + code + footer;