aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorLulonaut <lulonaut@tutanota.de>2023-07-06 01:50:43 +0200
committerGitHub <noreply@github.com>2023-07-06 09:50:43 +1000
commit1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4 (patch)
treeba2c436961af7a08753fa1b2cd7d8a0eaee0594d /src/main/kotlin
parentfe0017755ccb9701c2bd60236921d11faef3650b (diff)
downloadNotEnoughUpdates-1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4.tar.gz
NotEnoughUpdates-1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4.tar.bz2
NotEnoughUpdates-1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4.zip
fix MuseumTooltipManager NPE (#755)
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt8
1 files changed, 7 insertions, 1 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 d7c10dc1..3a7c69be 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
@@ -29,6 +29,7 @@ import io.github.moulberry.notenoughupdates.util.Utils
import io.github.moulberry.notenoughupdates.util.kotlin.KSerializable
import io.github.moulberry.notenoughupdates.util.stripControlCodes
import net.minecraft.inventory.ContainerChest
+import net.minecraft.util.EnumChatFormatting
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.io.File
@@ -51,7 +52,12 @@ object MuseumTooltipManager {
var data = MuseumData()
if (file.exists()) {
val content = file.readText()
- data = Gson().fromJson(content, MuseumData::class.java)
+ 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.")
+ }
} else {
file.createNewFile()
file.writeText(Gson().toJson(data))