aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-02 12:10:59 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-02 12:10:59 +0100
commitb99b36755dbd4121db38629b2abb6d1ad5d39fb8 (patch)
tree4d9361ed8656eabe3add92fcb9c57e18feba8860 /src/main/java/at
parenta11d12c0cc4202715ea4305f5bced886d6a7df4f (diff)
downloadskyhanni-b99b36755dbd4121db38629b2abb6d1ad5d39fb8.tar.gz
skyhanni-b99b36755dbd4121db38629b2abb6d1ad5d39fb8.tar.bz2
skyhanni-b99b36755dbd4121db38629b2abb6d1ad5d39fb8.zip
better shutdown logic
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt11
2 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index 0d806119f..9025703f5 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -187,10 +187,7 @@ class ConfigManager {
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.
- }
+ LorenzUtils.shutdownMinecraft("Config is corrupt inside developement enviroment.")
}
} else {
run()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 8ed5de686..7f5759a70 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -25,6 +25,7 @@ import net.minecraft.event.ClickEvent
import net.minecraft.event.HoverEvent
import net.minecraft.launchwrapper.Launch
import net.minecraft.util.ChatComponentText
+import net.minecraftforge.fml.common.FMLCommonHandler
import java.awt.Color
import java.lang.reflect.Field
import java.lang.reflect.Modifier
@@ -490,7 +491,7 @@ object LorenzUtils {
}
}
- fun List<String>.nextAfter(after: String, skip: Int = 1) = nextAfter({ it == after}, skip)
+ fun List<String>.nextAfter(after: String, skip: Int = 1) = nextAfter({ it == after }, skip)
fun List<String>.nextAfter(after: (String) -> Boolean, skip: Int = 1): String? {
var missing = -1
@@ -628,4 +629,12 @@ object LorenzUtils {
?: kotlin.error("Unknown enum constant for ${enumValues<T>().first().name.javaClass.simpleName}: '$name'")
fun isInDevEnviromen() = Launch.blackboard.get("fml.deobfuscatedEnvironment") as Boolean
+
+ fun shutdownMinecraft(reason: String? = null) {
+ System.err.println("SkyHanni-${SkyHanniMod.version} forced the game to shutdown.")
+ reason?.let {
+ System.err.println("Reason: $it")
+ }
+ FMLCommonHandler.instance().handleExit(-1)
+ }
}