diff options
author | jani270 <69345714+jani270@users.noreply.github.com> | 2024-01-13 20:04:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-13 20:04:39 +0100 |
commit | 2fc8c7bf35fcaf6c2ccc495f7b0eabd0ff74b1f0 (patch) | |
tree | 71c9e3bb8779b9625725557a69d120607eb0a90c /src/main/java/io | |
parent | 9613fe50e8f0076ed9a0b719052f4163960f9565 (diff) | |
download | NotEnoughUpdates-2fc8c7bf35fcaf6c2ccc495f7b0eabd0ff74b1f0.tar.gz NotEnoughUpdates-2fc8c7bf35fcaf6c2ccc495f7b0eabd0ff74b1f0.tar.bz2 NotEnoughUpdates-2fc8c7bf35fcaf6c2ccc495f7b0eabd0ff74b1f0.zip |
Fixed MinionHelper not loading slayers correctly (#1000)
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java | 34 |
1 files changed, 17 insertions, 17 deletions
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<String, Integer> slayerTier = new HashMap<>(); - if (player.has("slayer_bosses")) { - JsonObject slayerBosses = player.getAsJsonObject("slayer.slayer_bosses"); - for (Map.Entry<String, JsonElement> 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<String, JsonElement> 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; |