From a91739b54360508938031b100c4d11f3f678fcea Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Mon, 2 Oct 2023 23:58:34 +0200 Subject: [PATCH] Replace hardcoded plugin paths with centralized variable --- src/main/kotlin/fr/ziedelth/utils/plugins/JaisPlugin.kt | 4 ++-- src/main/kotlin/fr/ziedelth/utils/plugins/PluginManager.kt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/fr/ziedelth/utils/plugins/JaisPlugin.kt b/src/main/kotlin/fr/ziedelth/utils/plugins/JaisPlugin.kt index 5b9971d..897a32f 100644 --- a/src/main/kotlin/fr/ziedelth/utils/plugins/JaisPlugin.kt +++ b/src/main/kotlin/fr/ziedelth/utils/plugins/JaisPlugin.kt @@ -5,7 +5,7 @@ import org.pf4j.PluginWrapper import java.io.File abstract class JaisPlugin(pluginWrapper: PluginWrapper) : Plugin() { - private val pluginsFolder = File("plugins") + private val pluginsDirectory = PluginManager.pluginsDirectory get() { if (!field.exists()) { field.mkdirs() @@ -14,5 +14,5 @@ abstract class JaisPlugin(pluginWrapper: PluginWrapper) : Plugin() { return field } - val dataFolder = File(pluginsFolder, pluginWrapper.pluginId) + val dataFolder = File(pluginsDirectory, pluginWrapper.pluginId) } diff --git a/src/main/kotlin/fr/ziedelth/utils/plugins/PluginManager.kt b/src/main/kotlin/fr/ziedelth/utils/plugins/PluginManager.kt index da03e06..d45d916 100644 --- a/src/main/kotlin/fr/ziedelth/utils/plugins/PluginManager.kt +++ b/src/main/kotlin/fr/ziedelth/utils/plugins/PluginManager.kt @@ -7,7 +7,8 @@ import org.pf4j.DefaultPluginManager import java.io.File object PluginManager { - private var defaultPluginManager = DefaultPluginManager(File("data/plugins").toPath()) + val pluginsDirectory = File("data/plugins") + private var defaultPluginManager = DefaultPluginManager(pluginsDirectory.toPath()) val listeners = mutableListOf() fun loadPlugins() { @@ -23,7 +24,7 @@ object PluginManager { defaultPluginManager.stopPlugins() defaultPluginManager.unloadPlugins() listeners.clear() - defaultPluginManager = DefaultPluginManager(File("data/plugins").toPath()) + defaultPluginManager = DefaultPluginManager(pluginsDirectory.toPath()) loadPlugins() }