mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-28 00:41:31 +00:00
Initial work on scheduled backups.
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
package cloud.kubelet.foundation.core.abstraction
|
||||
|
||||
interface CoreFeature {
|
||||
fun enable()
|
||||
fun disable()
|
||||
fun module() = org.koin.dsl.module {}
|
||||
}
|
@ -7,13 +7,15 @@ import org.bukkit.event.Listener
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.koin.dsl.module
|
||||
import org.quartz.Scheduler
|
||||
|
||||
abstract class Feature : KoinComponent, Listener {
|
||||
abstract class Feature : CoreFeature, KoinComponent, Listener {
|
||||
private val plugin by inject<FoundationCorePlugin>()
|
||||
protected val scheduler by inject<Scheduler>()
|
||||
|
||||
open fun enable() {}
|
||||
open fun disable() {}
|
||||
open fun module() = module {}
|
||||
override fun enable() {}
|
||||
override fun disable() {}
|
||||
override fun module() = module {}
|
||||
|
||||
protected fun registerCommandExecutor(name: String, executor: CommandExecutor) {
|
||||
registerCommandExecutor(listOf(name), executor)
|
||||
|
@ -10,7 +10,7 @@ import org.koin.dsl.module
|
||||
abstract class FoundationPlugin : JavaPlugin() {
|
||||
private lateinit var pluginModule: Module
|
||||
private lateinit var pluginApplication: KoinApplication
|
||||
private lateinit var features: List<Feature>
|
||||
private lateinit var features: List<CoreFeature>
|
||||
private lateinit var module: Module
|
||||
|
||||
override fun onEnable() {
|
||||
@ -45,7 +45,10 @@ abstract class FoundationPlugin : JavaPlugin() {
|
||||
try {
|
||||
slF4JLogger.info("Enabling feature: ${it.javaClass.simpleName}")
|
||||
it.enable()
|
||||
server.pluginManager.registerEvents(it, this)
|
||||
// TODO: May replace this check with a method in the interface, CoreFeature would no-op.
|
||||
if (it is Feature) {
|
||||
server.pluginManager.registerEvents(it, this)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
slF4JLogger.error("Failed to enable feature: ${it.javaClass.simpleName}", e)
|
||||
}
|
||||
@ -61,5 +64,5 @@ abstract class FoundationPlugin : JavaPlugin() {
|
||||
}
|
||||
|
||||
protected open fun createModule() = module {}
|
||||
protected abstract fun createFeatures(): List<Feature>
|
||||
protected abstract fun createFeatures(): List<CoreFeature>
|
||||
}
|
||||
|
Reference in New Issue
Block a user