diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-30 00:48:01 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-30 00:48:01 +0100 |
commit | 90ff11ebbdbdbca7af6365344981f72dc3916fc0 (patch) | |
tree | 0be01c9f43f3e63d1e8c38ded64546566ce35631 /src | |
parent | 247d4d324dc9ce5960d8c94719707d232a89e3ad (diff) | |
download | skyhanni-90ff11ebbdbdbca7af6365344981f72dc3916fc0.tar.gz skyhanni-90ff11ebbdbdbca7af6365344981f72dc3916fc0.tar.bz2 skyhanni-90ff11ebbdbdbca7af6365344981f72dc3916fc0.zip |
Using a broken config no longer resets the config in dev env.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt | 16 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 3 |
2 files changed, 18 insertions, 1 deletions
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 <reified T : Enum<T>> enumValueOf(name: String) = enumValueOfOrNull<T>(name) ?: kotlin.error("Unknown enum constant for ${enumValues<T>().first().name.javaClass.simpleName}: '$name'") + + fun isInDevEnviromen() = Launch.blackboard.get("fml.deobfuscatedEnvironment") as Boolean } |