diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-30 15:26:11 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-30 15:26:11 +0100 |
commit | 83951beb85032ca11eede16a11adb27ccc6042a4 (patch) | |
tree | 1c507af5a23cac5d733d98e7ea68f23a806da495 /src/main/java/at/hannibal2/skyhanni/config | |
parent | 248edea686fb2580a339b2ca0c3668f3f1da0ff7 (diff) | |
download | skyhanni-83951beb85032ca11eede16a11adb27ccc6042a4.tar.gz skyhanni-83951beb85032ca11eede16a11adb27ccc6042a4.tar.bz2 skyhanni-83951beb85032ca11eede16a11adb27ccc6042a4.zip |
Added debug command /shconfigmanagerreset
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
4 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt index 37c2920a5..9708c513b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt @@ -5,14 +5,19 @@ import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper import io.github.moulberry.moulconfig.gui.MoulConfigEditor object ConfigGuiManager { - val editor by lazy { MoulConfigEditor(SkyHanniMod.configManager.processor) } + + var editor: MoulConfigEditor<Features>? = null fun openConfigGui(search: String? = null) { + if (editor == null) { + editor = MoulConfigEditor(SkyHanniMod.configManager.processor) + } + val editor = editor ?: return + if (search != null) { editor.search(search) } SkyHanniMod.screenToOpen = GuiScreenElementWrapper(editor) } - -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index a05d2de5d..bfbeb08df 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -109,6 +109,7 @@ class ConfigManager { private var configFile: File? = null private var sackFile: File? = null lateinit var processor: MoulConfigProcessor<Features> + private var disableSaving = false fun firstLoad() { if (::features.isInitialized) { @@ -217,6 +218,7 @@ class ConfigManager { } fun saveConfig(reason: String) { + if (disableSaving) return logger.log("saveConfig: $reason") val file = configFile ?: throw Error("Can not save config, configFile is null!") try { @@ -242,6 +244,7 @@ class ConfigManager { } fun saveSackData(reason: String) { + if (disableSaving) return logger.log("saveSackData: $reason") val file = sackFile ?: throw Error("Can not save sacks, sackFile is null!") try { @@ -256,4 +259,8 @@ class ConfigManager { e.printStackTrace() } } -}
\ No newline at end of file + + fun disableSaving() { + disableSaving = true + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 3fdc56073..ea77de371 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -284,6 +284,10 @@ object Commands { "shplaysound", "Play the specified sound effect at the given pitch and volume." ) { SoundUtils.command(it) } + registerCommand( + "shconfigmanagerreset", + "Reloads the config manager and rendering processors of MoulConfig. This §cWILL RESET §7your config, but also updating the java config files (names, description, orderings and stuff)." + ) { SkyHanniDebugsAndTests.configManagerResetCommand(it) } } private fun internalCommands() { diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/About.java b/src/main/java/at/hannibal2/skyhanni/config/features/About.java index 349cb7466..258ba6985 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/About.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/About.java @@ -81,4 +81,4 @@ public class About { @ConfigEditorButton(buttonText = "GitHub") public Runnable discordRPC = () -> OSUtils.openBrowser("https://github.com/jagrosh/DiscordIPC"); } -}
\ No newline at end of file +} |