diff options
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; |