Live remove/reload

This commit is contained in:
downthecrop 2025-09-18 20:14:22 -07:00
parent dc70d4406e
commit c74e5f2a4d

View file

@ -1172,6 +1172,7 @@ object ReflectiveEditorView : View {
// Helper method to handle duplicate plugins (loaded and disabled)
private fun handleDuplicatePlugins(loadedPluginNames: Set<String>, disabledPluginInfo: Map<String, String>) {
var needsReload = false
for (pluginName in loadedPluginNames) {
if (disabledPluginInfo.containsKey(pluginName)) {
System.out.println("Found duplicate plugin: $pluginName. Deleting disabled version.")
@ -1181,6 +1182,7 @@ object ReflectiveEditorView : View {
if (pluginDir.exists() && pluginDir.isDirectory) {
if (deleteRecursively(pluginDir)) {
System.out.println("Successfully deleted disabled version of $pluginName")
needsReload = true
} else {
System.out.println("Failed to delete disabled version of $pluginName")
}
@ -1190,6 +1192,11 @@ object ReflectiveEditorView : View {
}
}
}
// Reload plugins if we deleted any disabled duplicates
if (needsReload) {
PluginRepository.reloadPlugins()
}
}
// Helper method to get disabled plugin names and their versions
@ -1261,6 +1268,12 @@ object ReflectiveEditorView : View {
// Recursively delete the directory
if (deleteRecursively(pluginDir)) {
showToast(mainPanel, "Plugin deleted successfully", JOptionPane.INFORMATION_MESSAGE)
// If we deleted a loaded plugin, reload plugins
if (!isDisabled) {
PluginRepository.reloadPlugins()
}
// Refresh the plugin list view
SwingUtilities.invokeLater {
addPlugins(reflectiveEditorView!!)