From 5c6ac5e309019f8216f5f020c82888d224cee3f9 Mon Sep 17 00:00:00 2001
From: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Date: Wed, 1 Nov 2023 21:10:48 +0100
Subject: Made the esc -> mod options -> SkyHanni -> config button not crash
 you.

---
 .../java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt     | 4 ++--
 src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt     | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

(limited to 'src')

diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt
index a8190ca5b..94f609c6e 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt
@@ -18,7 +18,7 @@ class ConfigGuiForgeInterop : IModGuiFactory {
 
     override fun getHandlerFor(element: RuntimeOptionCategoryElement): RuntimeOptionGuiHandler? = null
 
-    class WrappedSkyHanniConfig(private val parent: GuiScreen) : GuiScreenElementWrapper(ConfigGuiManager.editor) {
+    class WrappedSkyHanniConfig(private val parent: GuiScreen) : GuiScreenElementWrapper(ConfigGuiManager.getEditorInstance()) {
         @Throws(IOException::class)
         override fun handleKeyboardInput() {
             if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
@@ -28,4 +28,4 @@ class ConfigGuiForgeInterop : IModGuiFactory {
             super.handleKeyboardInput()
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt
index 9708c513b..f6bcd3bbc 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt
@@ -8,11 +8,10 @@ object ConfigGuiManager {
 
     var editor: MoulConfigEditor<Features>? = null
 
+    fun getEditorInstance() = editor ?: MoulConfigEditor(SkyHanniMod.configManager.processor).also { editor = it }
+
     fun openConfigGui(search: String? = null) {
-        if (editor == null) {
-            editor = MoulConfigEditor(SkyHanniMod.configManager.processor)
-        }
-        val editor = editor ?: return
+        val editor = getEditorInstance()
 
         if (search != null) {
             editor.search(search)
-- 
cgit