diff options
author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2023-08-05 23:15:48 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-05 15:15:48 +0200 |
commit | 3c9e4c7c1874bee803ad8c241fff83fd5588cda8 (patch) | |
tree | a6e743360beef65b091d76c575b271c88e7c0bc5 /src/main | |
parent | 42c0ffec59967355e94aefecf9e269a47b2a7b19 (diff) | |
download | NotEnoughUpdates-3c9e4c7c1874bee803ad8c241fff83fd5588cda8.tar.gz NotEnoughUpdates-3c9e4c7c1874bee803ad8c241fff83fd5588cda8.tar.bz2 NotEnoughUpdates-3c9e4c7c1874bee803ad8c241fff83fd5588cda8.zip |
Fix crash with invalid meusum data (#789)
try catch crash
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt index 3a7c69be..675708e9 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt @@ -51,11 +51,15 @@ object MuseumTooltipManager { private val loadedMuseumDataDelegate = lazy { var data = MuseumData() if (file.exists()) { - val content = file.readText() - val loadedData = Gson().fromJson(content, MuseumData::class.java) - if (loadedData != null) { - data = loadedData - } else { + try { + val content = file.readText() + val loadedData = Gson().fromJson(content, MuseumData::class.java) + if (loadedData != null) { + data = loadedData + } else { + Utils.addChatMessage("${EnumChatFormatting.RED}${EnumChatFormatting.BOLD}[NEU] Error while reading existing museum data, resetting.") + } + } catch (ignored: Exception) { Utils.addChatMessage("${EnumChatFormatting.RED}${EnumChatFormatting.BOLD}[NEU] Error while reading existing museum data, resetting.") } } else { |