From 2fc8c7bf35fcaf6c2ccc495f7b0eabd0ff74b1f0 Mon Sep 17 00:00:00 2001 From: jani270 <69345714+jani270@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:04:39 +0100 Subject: Fixed MinionHelper not loading slayers correctly (#1000) --- .../loaders/MinionHelperApiLoader.java | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java index 1f3bc0d1..2b583810 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java @@ -133,25 +133,25 @@ public class MinionHelperApiLoader { JsonObject slayerLeveling = Constants.LEVELING.getAsJsonObject("slayer_xp"); Map slayerTier = new HashMap<>(); - if (player.has("slayer_bosses")) { - JsonObject slayerBosses = player.getAsJsonObject("slayer.slayer_bosses"); - for (Map.Entry entry : slayerBosses.entrySet()) { - String name = entry.getKey(); - JsonObject slayerEntry = entry.getValue().getAsJsonObject(); - if (slayerEntry.has("xp")) { - long xp = slayerEntry.get("xp").getAsLong(); - - int tier = 0; - for (JsonElement element : slayerLeveling.getAsJsonArray(name)) { - int needForLevel = element.getAsInt(); - if (xp >= needForLevel) { - tier++; - } else { - break; - } + JsonObject slayerBosses = Utils + .getElementOrDefault(player, "slayer.slayer_bosses", new JsonObject()) + .getAsJsonObject(); + for (Map.Entry entry : slayerBosses.entrySet()) { + String name = entry.getKey(); + JsonObject slayerEntry = entry.getValue().getAsJsonObject(); + if (slayerEntry.has("xp")) { + long xp = slayerEntry.get("xp").getAsLong(); + + int tier = 0; + for (JsonElement element : slayerLeveling.getAsJsonArray(name)) { + int needForLevel = element.getAsInt(); + if (xp >= needForLevel) { + tier++; + } else { + break; } - slayerTier.put(name, tier); } + slayerTier.put(name, tier); } } return slayerTier; -- cgit