From c98a1fbc727cfd33294346bc9fc27767e4a2545b Mon Sep 17 00:00:00 2001 From: jani270 <69345714+jani270@users.noreply.github.com> Date: Thu, 14 Dec 2023 18:03:20 +0100 Subject: Hopefully fixed 2 rift page crashes (#971) --- .../profileviewer/rift/RiftPage.java | 28 +++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java index 910f8595..85fc7ee5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java @@ -119,15 +119,27 @@ public class RiftPage extends GuiProfileViewerPage { Minecraft.getMinecraft().getTextureManager().bindTexture(GuiProfileViewer.pv_elements); Utils.drawTexturedRect(guiLeft + 35, guiTop + 156, 20, 20, 0, 20 / 256f, 0, 20 / 256f, GL11.GL_NEAREST); - JsonObject deadCats = riftData.getAsJsonObject("dead_cats"); + JsonObject deadCats = Utils.getElementOrDefault( + selectedProfile.getProfileJson(), + "rift.dead_cats", + new JsonObject() + ).getAsJsonObject(); if (deadCats != null && !deadCats.entrySet().isEmpty() && deadCats.has("found_cats")) { - JsonArray foundCats = deadCats.getAsJsonArray("found_cats"); + JsonArray foundCats = Utils.getElementOrDefault( + selectedProfile.getProfileJson(), + "rift.dead_cats.found_cats", + new JsonArray() + ).getAsJsonArray(); int size = foundCats.size(); int riftTime = size * 15; int manaRegen = size * 2; - JsonObject montezuma = deadCats.getAsJsonObject("montezuma"); + JsonObject montezuma = Utils.getElementOrDefault( + selectedProfile.getProfileJson(), + "rift.dead_cats.montezuma", + new JsonObject() + ).getAsJsonObject(); if (montezuma != null) { String montezumaType = montezuma.get("type").getAsString(); @@ -261,11 +273,11 @@ public class RiftPage extends GuiProfileViewerPage { } } - JsonObject enigma = riftData.getAsJsonObject("enigma"); - int foundSouls = 0; - if (enigma.has("found_souls")) { - foundSouls = enigma.getAsJsonArray("found_souls").size(); - } + int foundSouls = Utils.getElementOrDefault( + selectedProfile.getProfileJson(), + "rift.enigma.found_souls", + new JsonArray() + ).getAsJsonArray().size(); Utils.renderAlignedString( EnumChatFormatting.DARK_PURPLE + "Enigma Souls:", -- cgit