diff options
author | Lulonaut <lulonaut@tutanota.de> | 2023-07-06 01:50:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 09:50:43 +1000 |
commit | 1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4 (patch) | |
tree | ba2c436961af7a08753fa1b2cd7d8a0eaee0594d /src/main/kotlin/io | |
parent | fe0017755ccb9701c2bd60236921d11faef3650b (diff) | |
download | NotEnoughUpdates-1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4.tar.gz NotEnoughUpdates-1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4.tar.bz2 NotEnoughUpdates-1fbb1b2407ed207ab6d52f1c4a8644d93ad267c4.zip |
fix MuseumTooltipManager NPE (#755)
Diffstat (limited to 'src/main/kotlin/io')
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/inventory/MuseumTooltipManager.kt | 8 |
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)) |