aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorLulonaut <lulonaut@lulonaut.tech>2024-02-13 13:37:20 +0100
committerGitHub <noreply@github.com>2024-02-13 23:37:20 +1100
commit028c8c6b0620b1c7f4f71f7d7991de42130f9d6e (patch)
treeb8990a5dd98c6282493d00fc3109bb0dd7bcb34b /src/main/java/io
parent0a12055a788865ab37483695e2f3c18175b79ae0 (diff)
downloadNotEnoughUpdates-028c8c6b0620b1c7f4f71f7d7991de42130f9d6e.tar.gz
NotEnoughUpdates-028c8c6b0620b1c7f4f71f7d7991de42130f9d6e.tar.bz2
NotEnoughUpdates-028c8c6b0620b1c7f4f71f7d7991de42130f9d6e.zip
Fix crash when parsing bestiary/trophy fish data (#1018)
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java
index f26cab17..253ff17e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
+ * Copyright (C) 2022-2024 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
@@ -383,7 +383,8 @@ public class TrophyFishPage extends GuiProfileViewerPage {
totalCount = 0;
for (Map.Entry<String, JsonElement> stringJsonElementEntry : trophyObject.entrySet()) {
String key = stringJsonElementEntry.getKey();
- if (key.equalsIgnoreCase("rewards") || key.equalsIgnoreCase("total_caught")) {
+ if (key.equalsIgnoreCase("rewards") || key.equalsIgnoreCase("total_caught") ||
+ key.equalsIgnoreCase("last_caught")) {
if (key.equalsIgnoreCase("total_caught")) {
totalCount = stringJsonElementEntry.getValue().getAsInt();
}
@@ -393,7 +394,12 @@ public class TrophyFishPage extends GuiProfileViewerPage {
String[] s = key.split("_");
String type = s[s.length - 1];
TrophyFish.TrophyFishRarity trophyFishRarity;
- int value = stringJsonElementEntry.getValue().getAsInt();
+ int value = 0;
+ try {
+ value = stringJsonElementEntry.getValue().getAsInt();
+ } catch (NumberFormatException e) {
+ value = -1;
+ }
if (key.startsWith("golden_fish_")) {
type = s[2];