Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Replace hardcoded plugin paths with centralized variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Oct 2, 2023
1 parent 793fc95 commit a91739b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/fr/ziedelth/utils/plugins/JaisPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -14,5 +14,5 @@ abstract class JaisPlugin(pluginWrapper: PluginWrapper) : Plugin() {
return field
}

val dataFolder = File(pluginsFolder, pluginWrapper.pluginId)
val dataFolder = File(pluginsDirectory, pluginWrapper.pluginId)
}
5 changes: 3 additions & 2 deletions src/main/kotlin/fr/ziedelth/utils/plugins/PluginManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Listener>()

fun loadPlugins() {
Expand All @@ -23,7 +24,7 @@ object PluginManager {
defaultPluginManager.stopPlugins()
defaultPluginManager.unloadPlugins()
listeners.clear()
defaultPluginManager = DefaultPluginManager(File("data/plugins").toPath())
defaultPluginManager = DefaultPluginManager(pluginsDirectory.toPath())
loadPlugins()
}

Expand Down

0 comments on commit a91739b

Please sign in to comment.