diff --git a/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/config/ConfigManager.java b/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/config/ConfigManager.java index 5777ada..d8c1605 100644 --- a/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/config/ConfigManager.java +++ b/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/config/ConfigManager.java @@ -49,6 +49,11 @@ public void init() { logger.info("Creating config file..."); configLoader.saveToFile(config); } + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + logger.info("SHUTDOWN - Saving config to file..."); + saveToFile(); + })); } public void saveToFile() { diff --git a/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/gui/dialog/PluginOutput.kt b/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/gui/dialog/PluginOutput.kt index e6b9d8e..41ba004 100644 --- a/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/gui/dialog/PluginOutput.kt +++ b/EOCV-Sim/src/main/java/com/github/serivesmejia/eocvsim/gui/dialog/PluginOutput.kt @@ -98,6 +98,7 @@ class PluginOutput( } private val output = JDialog() + private val tabbedPane: JTabbedPane private val mavenBottomButtonsPanel: MavenOutputBottomButtonsPanel = MavenOutputBottomButtonsPanel(::close) { mavenOutputPanel.outputArea.text @@ -108,9 +109,16 @@ class PluginOutput( init { output.isModal = true output.isAlwaysOnTop = true - output.title = "Plugin Output" + output.title = "Plugin Manager" - output.add(JTabbedPane().apply { + tabbedPane = JTabbedPane() + + output.add(tabbedPane.apply { + addTab("Plugins", JPanel().apply { + layout = BoxLayout(this, BoxLayout.PAGE_AXIS) + + add(JLabel("Plugins output will be shown here")) + }) addTab("Output", mavenOutputPanel) }) @@ -156,6 +164,9 @@ class PluginOutput( if(!text.startsWith(SPECIAL_SILENT) && text != SPECIAL_CLOSE && text != SPECIAL_FREE) { SwingUtilities.invokeLater { + SwingUtilities.invokeLater { + tabbedPane.selectedIndex = tabbedPane.indexOfTab("Output") // focus on output tab + } output.isVisible = true } } diff --git a/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginLoader.kt b/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginLoader.kt index ace814d..183ced5 100644 --- a/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginLoader.kt +++ b/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginLoader.kt @@ -198,7 +198,7 @@ class PluginLoader( fun enable() { if(enabled || !loaded) return - logger.info("Enabling plugin $pluginName v$pluginVersion") + appender.appendln("${PluginOutput.SPECIAL_SILENT}Enabling plugin $pluginName v$pluginVersion") plugin.enabled = true plugin.onEnable() @@ -212,7 +212,7 @@ class PluginLoader( fun disable() { if(!enabled || !loaded) return - logger.info("Disabling plugin $pluginName v$pluginVersion") + appender.appendln("${PluginOutput.SPECIAL_SILENT}Disabling plugin $pluginName v$pluginVersion") plugin.enabled = false plugin.onDisable() diff --git a/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginManager.kt b/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginManager.kt index 9ce1f49..9ce1a5a 100644 --- a/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginManager.kt +++ b/EOCV-Sim/src/main/java/io/github/deltacv/eocvsim/plugin/loader/PluginManager.kt @@ -163,7 +163,8 @@ class PluginManager(val eocvSim: EOCVSim) { loader.load() _loadedPluginHashes.add(hash) } catch (e: Throwable) { - appender.appendln("Failure loading ${loader.pluginName} v${loader.pluginVersion}: ${e.message}") + appender.appendln("Failure loading ${loader.pluginName} v${loader.pluginVersion}:") + appender.appendln(e.message ?: "Unknown error") logger.error("Failure loading ${loader.pluginName} v${loader.pluginVersion}", e) loaders.remove(file)