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