Initial work on scheduled backups.

This commit is contained in:
Logan Gorence
2021-12-24 08:38:57 +00:00
parent b2851d13b9
commit c1f621aa7b
12 changed files with 119 additions and 8 deletions

View File

@ -0,0 +1,7 @@
package cloud.kubelet.foundation.core.abstraction
interface CoreFeature {
fun enable()
fun disable()
fun module() = org.koin.dsl.module {}
}

View File

@ -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)

View File

@ -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>
}