From 90ff11ebbdbdbca7af6365344981f72dc3916fc0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:48:01 +0100 Subject: Using a broken config no longer resets the config in dev env. --- .../java/at/hannibal2/skyhanni/config/ConfigManager.kt | 16 +++++++++++++++- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index b59bf1141..0d806119f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzRarity +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -180,7 +181,20 @@ class ConfigManager { output = if (fileType == ConfigFileType.FEATURES) { val jsonObject = gson.fromJson(bufferedReader.readText(), JsonObject::class.java) val newJsonObject = ConfigUpdaterMigrator.fixConfig(jsonObject) - gson.fromJson(newJsonObject, defaultValue.javaClass) + val run = { gson.fromJson(newJsonObject, defaultValue.javaClass) } + if (LorenzUtils.isInDevEnviromen()) { + try { + run() + } catch (e: Throwable) { + e.printStackTrace() + println("This is a crash.") + while (true) { + // If you know the forge method to shut down correctly, please quietly pr it. + } + } + } else { + run() + } } else { gson.fromJson(bufferedReader.readText(), defaultValue.javaClass) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index e82ce0da1..8ed5de686 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -23,6 +23,7 @@ import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.SharedMonsterAttributes import net.minecraft.event.ClickEvent import net.minecraft.event.HoverEvent +import net.minecraft.launchwrapper.Launch import net.minecraft.util.ChatComponentText import java.awt.Color import java.lang.reflect.Field @@ -625,4 +626,6 @@ object LorenzUtils { inline fun > enumValueOf(name: String) = enumValueOfOrNull(name) ?: kotlin.error("Unknown enum constant for ${enumValues().first().name.javaClass.simpleName}: '$name'") + + fun isInDevEnviromen() = Launch.blackboard.get("fml.deobfuscatedEnvironment") as Boolean } -- cgit