From d1f618d8e952ee2ac2cba4b97df7677773c66472 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Fri, 21 Oct 2022 06:32:47 +0000 Subject: Fix dungeon page going blank (#382) 382/merge --- .../moulberry/notenoughupdates/profileviewer/DungeonPage.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java index 15a70ded..6d59db27 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java @@ -124,7 +124,6 @@ public class DungeonPage extends GuiProfileViewerPage { ProfileViewer.Profile profile = GuiProfileViewer.getProfile(); String profileId = GuiProfileViewer.getProfileId(); JsonObject hypixelInfo = profile.getHypixelProfile(); - if (hypixelInfo == null) return; JsonObject profileInfo = profile.getProfileInformation(profileId); if (profileInfo == null) return; @@ -443,7 +442,10 @@ public class DungeonPage extends GuiProfileViewerPage { //Random stats - float secrets = Utils.getElementAsFloat(Utils.getElement(hypixelInfo, "achievements.skyblock_treasure_hunter"), 0); + float secrets = -1; + if (hypixelInfo != null) { + secrets = Utils.getElementAsFloat(Utils.getElement(hypixelInfo, "achievements.skyblock_treasure_hunter"), 0); + } float totalRunsF = 0; float totalRunsF5 = 0; for (int i = 1; i <= 7; i++) { @@ -507,14 +509,14 @@ public class DungeonPage extends GuiProfileViewerPage { ); Utils.renderAlignedString( EnumChatFormatting.YELLOW + "Secrets (Total) ", - EnumChatFormatting.WHITE + StringUtils.shortNumberFormat(secrets), + EnumChatFormatting.WHITE + (secrets == -1 ? "?" : StringUtils.shortNumberFormat(secrets)), x, miscTopY + 20, sectionWidth ); Utils.renderAlignedString( EnumChatFormatting.YELLOW + "Secrets (/Run) ", - EnumChatFormatting.WHITE.toString() + (Math.round(secrets / Math.max(1, totalRuns) * 100) / 100f), + EnumChatFormatting.WHITE.toString() + (secrets == -1 ? "?" : (Math.round(secrets / Math.max(1, totalRuns) * 100) / 100f)), x, miscTopY + 30, sectionWidth -- cgit