Skip to content

Commit 14cb2ef

Browse files
committed
fix color parsing
1 parent c58380c commit 14cb2ef

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/com/cleanroommc/modularui/test/EventHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void onRichTooltip(RichTooltipEvent.Pre event) {
7272
}
7373

7474
@SubscribeEvent
75-
public static void onThemeTooltip(ReloadThemeEvent.Pre event) {
75+
public void onThemeTooltip(ReloadThemeEvent.Pre event) {
7676
IThemeApi.get().registerTheme(testTheme);
7777
}
7878
}

src/main/java/com/cleanroommc/modularui/utils/Color.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,9 @@ public static int ofJson(JsonElement jsonElement) {
758758
if (jsonElement.isJsonPrimitive()) {
759759
String colorString = jsonElement.getAsString();
760760
if (colorString.isEmpty()) return WHITE.main;
761-
if (colorString.charAt(0) == '0' || colorString.charAt(0) == '#') {
761+
char c = colorString.charAt(0);
762+
// a normal int string
763+
if (Character.isDigit(c) || c == '-' || c == '#') {
762764
int color = (int) (long) Long.decode(colorString); // bruh
763765
if (color != 0 && getAlpha(color) == 0) {
764766
return withAlpha(color, 255);

0 commit comments

Comments
 (0)