diff options
Diffstat (limited to 'src/main/java/io')
4 files changed, 28 insertions, 23 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java index 8bb26b09..8eb577d2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java @@ -128,13 +128,14 @@ public class CoreTaskLevel { } int sbXpBankUpgrades = 0; - - JsonArray completedTasks = object.getAsJsonObject("leveling").get("completed_tasks").getAsJsonArray(); - JsonObject bankUpgradesXp = coreTask.getAsJsonObject("bank_upgrades_xp"); - for (JsonElement completedTask : completedTasks) { - String name = completedTask.getAsString(); - if (bankUpgradesXp.has(name)) { - sbXpBankUpgrades += bankUpgradesXp.get(name).getAsInt(); + if (object.has("leveling") && object.getAsJsonObject("leveling").has("completed_tasks")) { + JsonArray completedTasks = object.getAsJsonObject("leveling").get("completed_tasks").getAsJsonArray(); + JsonObject bankUpgradesXp = coreTask.getAsJsonObject("bank_upgrades_xp"); + for (JsonElement completedTask : completedTasks) { + String name = completedTask.getAsString(); + if (bankUpgradesXp.has(name)) { + sbXpBankUpgrades += bankUpgradesXp.get(name).getAsInt(); + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java index 04ace872..a5dc994a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java @@ -56,12 +56,14 @@ public class EventTaskLevel { sbXpMiningFiesta = getCapOrAmount(miningFiestaOresMined, 1_000_000, 5_000); sbXpFishingFestival = getCapOrAmount(fishingFestivalSharksKilled, 5_000, 50); - JsonArray completedTasks = leveling.get("completed_tasks").getAsJsonArray(); - JsonObject spookyFestivalXp = eventTask.getAsJsonObject("spooky_festival_xp"); - for (JsonElement completedTask : completedTasks) { - String name = completedTask.getAsString(); - if (spookyFestivalXp.has(name)) { - sbXpSpookyFestival += spookyFestivalXp.get(name).getAsInt(); + if (leveling.has("completed_tasks")) { + JsonArray completedTasks = leveling.get("completed_tasks").getAsJsonArray(); + JsonObject spookyFestivalXp = eventTask.getAsJsonObject("spooky_festival_xp"); + for (JsonElement completedTask : completedTasks) { + String name = completedTask.getAsString(); + if (spookyFestivalXp.has(name)) { + sbXpSpookyFestival += spookyFestivalXp.get(name).getAsInt(); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java index 8b7b9d2b..c9ba7636 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java @@ -88,12 +88,14 @@ public class MiscTaskLevel { // abiphone JsonObject leveling = object.getAsJsonObject("leveling"); - JsonArray completedTask = leveling.get("completed_tasks").getAsJsonArray(); - Stream<JsonElement> stream = StreamSupport.stream(completedTask.spliterator(), true); - long activeContacts = stream.map(JsonElement::getAsString).filter(s -> s.startsWith("ABIPHONE_")).count(); - JsonObject abiphone = netherIslandPlayerData.getAsJsonObject("abiphone"); - if (abiphone.has("active_contacts")) { - sbXpAbiphone = (int) activeContacts * miscellaneousTask.get("abiphone_contacts_xp").getAsInt(); + if (leveling.has("completed_tasks")) { + JsonArray completedTask = leveling.get("completed_tasks").getAsJsonArray(); + Stream<JsonElement> stream = StreamSupport.stream(completedTask.spliterator(), true); + long activeContacts = stream.map(JsonElement::getAsString).filter(s -> s.startsWith("ABIPHONE_")).count(); + JsonObject abiphone = netherIslandPlayerData.getAsJsonObject("abiphone"); + if (abiphone.has("active_contacts")) { + sbXpAbiphone = (int) activeContacts * miscellaneousTask.get("abiphone_contacts_xp").getAsInt(); + } } } @@ -101,8 +103,8 @@ public class MiscTaskLevel { int sbXpGainedHarp = 0; JsonObject harpSongsNames = miscellaneousTask.get("harp_songs_names").getAsJsonObject(); - JsonObject leveling = object.get("leveling").getAsJsonObject(); - if (leveling.has("completed_tasks")) { + JsonObject leveling = object.getAsJsonObject("leveling"); + if (leveling != null && leveling.has("completed_tasks")) { JsonArray completedTasks = leveling.get("completed_tasks").getAsJsonArray(); for (JsonElement completedTask : completedTasks) { String name = completedTask.getAsString(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java index 06ab6f8c..176fc899 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java @@ -167,8 +167,8 @@ public class SkillRelatedTaskLevel { } int sbXpNucleus = 0; - JsonObject leveling = object.get("leveling").getAsJsonObject(); - if (leveling.has("completions") && leveling.getAsJsonObject("completions").has("NUCLEUS_RUNS")) { + JsonObject leveling = object.getAsJsonObject("leveling"); + if (leveling != null && leveling.has("completions") && leveling.getAsJsonObject("completions").has("NUCLEUS_RUNS")) { int nucleusRuns = leveling.getAsJsonObject("completions").get("NUCLEUS_RUNS").getAsInt(); JsonElement nucleusXp = miningObj.get("crystal_nucleus_xp"); if (nucleusXp == null) { |