mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-02 13:10:55 +00:00
Reorganize feature + module init to fix bug.
This commit is contained in:
parent
c854e7c47c
commit
2c98cacf96
@ -1,6 +1,5 @@
|
||||
package cloud.kubelet.foundation.core
|
||||
|
||||
import cloud.kubelet.foundation.core.abstraction.Feature
|
||||
import cloud.kubelet.foundation.core.abstraction.FoundationPlugin
|
||||
import cloud.kubelet.foundation.core.features.backup.BackupFeature
|
||||
import cloud.kubelet.foundation.core.features.dev.DevFeature
|
||||
@ -13,15 +12,6 @@ import java.nio.file.Path
|
||||
|
||||
class FoundationCorePlugin : FoundationPlugin() {
|
||||
private lateinit var _pluginDataPath: Path
|
||||
override val features: List<Feature>
|
||||
get() = listOf(
|
||||
BackupFeature(),
|
||||
DevFeature(),
|
||||
PlayerFeature(),
|
||||
StatsFeature(),
|
||||
UpdateFeature(),
|
||||
WorldFeature(),
|
||||
)
|
||||
|
||||
var pluginDataPath: Path
|
||||
/**
|
||||
@ -38,10 +28,6 @@ class FoundationCorePlugin : FoundationPlugin() {
|
||||
_pluginDataPath = value
|
||||
}
|
||||
|
||||
override fun module() = module {
|
||||
single { this@FoundationCorePlugin }
|
||||
}
|
||||
|
||||
override fun onEnable() {
|
||||
// Create core plugin directory.
|
||||
pluginDataPath = dataFolder.toPath()
|
||||
@ -49,4 +35,17 @@ class FoundationCorePlugin : FoundationPlugin() {
|
||||
|
||||
super.onEnable()
|
||||
}
|
||||
|
||||
override fun createFeatures() = listOf(
|
||||
BackupFeature(),
|
||||
DevFeature(),
|
||||
PlayerFeature(),
|
||||
StatsFeature(),
|
||||
UpdateFeature(),
|
||||
WorldFeature(),
|
||||
)
|
||||
|
||||
override fun createModule() = module {
|
||||
single { this@FoundationCorePlugin }
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ import org.koin.dsl.module
|
||||
abstract class FoundationPlugin : JavaPlugin() {
|
||||
private lateinit var pluginModule: Module
|
||||
private lateinit var pluginApplication: KoinApplication
|
||||
protected abstract val features: List<Feature>
|
||||
private lateinit var features: List<Feature>
|
||||
private lateinit var module: Module
|
||||
|
||||
override fun onEnable() {
|
||||
pluginModule = module {
|
||||
@ -20,11 +21,14 @@ abstract class FoundationPlugin : JavaPlugin() {
|
||||
single { slF4JLogger }
|
||||
}
|
||||
|
||||
features = createFeatures()
|
||||
module = createModule()
|
||||
|
||||
// TODO: If we have another plugin using this class, we may need to use context isolation.
|
||||
// https://insert-koin.io/docs/reference/koin-core/context-isolation
|
||||
pluginApplication = startKoin {
|
||||
modules(pluginModule)
|
||||
modules(module())
|
||||
modules(module)
|
||||
}
|
||||
|
||||
features.forEach {
|
||||
@ -50,5 +54,6 @@ abstract class FoundationPlugin : JavaPlugin() {
|
||||
stopKoin()
|
||||
}
|
||||
|
||||
protected open fun module() = module {}
|
||||
protected open fun createModule() = module {}
|
||||
protected abstract fun createFeatures(): List<Feature>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user