From 1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4 Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Thu, 6 Jul 2023 01:50:43 +0200 Subject: fix MuseumTooltipManager NPE (#755) --- .../miscfeatures/inventory/MuseumTooltipManager.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)) -- cgit