diff options
author | jani270 <69345714+jani270@users.noreply.github.com> | 2023-12-14 18:03:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-14 18:03:20 +0100 |
commit | c98a1fbc727cfd33294346bc9fc27767e4a2545b (patch) | |
tree | cf00b1248e83dfe1df3d69f6d58619969179afb1 | |
parent | a1b74ca22b8079455d5caabc8f5cc6613a85f285 (diff) | |
download | NotEnoughUpdates-c98a1fbc727cfd33294346bc9fc27767e4a2545b.tar.gz NotEnoughUpdates-c98a1fbc727cfd33294346bc9fc27767e4a2545b.tar.bz2 NotEnoughUpdates-c98a1fbc727cfd33294346bc9fc27767e4a2545b.zip |
Hopefully fixed 2 rift page crashes (#971)
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java | 28 |
1 files changed, 20 insertions, 8 deletions
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:", |