From 974f03b262b9a84ab52ca8ff63d207c923c21601 Mon Sep 17 00:00:00 2001 From: Vixid <52578495+VixidDev@users.noreply.github.com> Date: Fri, 3 Mar 2023 13:15:07 +0000 Subject: Fixed colour formatting on sb levels >= 360 (#638) --- .../notenoughupdates/profileviewer/ProfileViewer.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index 6f8427ae..62f55fd7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -963,30 +963,29 @@ public class ProfileViewer { } double skyblockLevel = getSkyblockLevel(profileName); + EnumChatFormatting levelColour = EnumChatFormatting.WHITE; - EnumChatFormatting previousColor = EnumChatFormatting.WHITE; if (Constants.SBLEVELS == null || !Constants.SBLEVELS.has("sblevel_colours")) { Utils.showOutdatedRepoNotification(); return EnumChatFormatting.WHITE; } + JsonObject sblevelColours = Constants.SBLEVELS.getAsJsonObject("sblevel_colours"); try { for (Map.Entry stringJsonElementEntry : sblevelColours.entrySet()) { - int key = Integer.parseInt(stringJsonElementEntry.getKey()); + int nextLevelBracket = Integer.parseInt(stringJsonElementEntry.getKey()); EnumChatFormatting valueByName = EnumChatFormatting.getValueByName(stringJsonElementEntry .getValue() .getAsString()); - if (skyblockLevel <= key) { - skyBlockExperienceColour.put(profileName, previousColor); - return previousColor; + if (skyblockLevel >= nextLevelBracket) { + levelColour = valueByName; } - previousColor = valueByName; } } catch (RuntimeException ignored) { // catch both numberformat and getValueByName being wrong } - skyBlockExperienceColour.put(profileName, EnumChatFormatting.WHITE); - return EnumChatFormatting.WHITE; + skyBlockExperienceColour.put(profileName, levelColour); + return levelColour; } public double getSkyblockLevel(String profileName) { -- cgit