Files
foundation/foundation-core/src/main/kotlin/gay/pizza/foundation/core/FoundationCorePlugin.kt

60 lines
1.7 KiB
Kotlin
Raw Normal View History

2023-01-24 21:37:24 -08:00
package gay.pizza.foundation.core
2021-12-21 00:58:22 +00:00
import gay.pizza.foundation.common.PluginMainClass
2023-01-24 21:37:24 -08:00
import gay.pizza.foundation.core.abstraction.FoundationPlugin
import gay.pizza.foundation.core.features.backup.BackupFeature
import gay.pizza.foundation.core.features.dev.DevFeature
import gay.pizza.foundation.core.features.gameplay.GameplayFeature
import gay.pizza.foundation.core.features.persist.PersistenceFeature
import gay.pizza.foundation.core.features.player.PlayerFeature
import gay.pizza.foundation.core.features.scheduler.SchedulerFeature
import gay.pizza.foundation.core.features.stats.StatsFeature
import gay.pizza.foundation.core.features.update.UpdateFeature
import gay.pizza.foundation.core.features.world.WorldFeature
2021-12-23 22:44:02 +00:00
import org.koin.dsl.module
import java.nio.file.Path
2021-12-21 00:58:22 +00:00
@PluginMainClass
2021-12-23 22:44:02 +00:00
class FoundationCorePlugin : FoundationPlugin() {
private lateinit var _pluginDataPath: Path
var pluginDataPath: Path
/**
* Data path of the core plugin.
* Can be used as a check of sorts for dependencies to be sure the plugin is loaded.
*/
get() {
if (!::_pluginDataPath.isInitialized) {
throw Exception("FoundationCore is not loaded!")
}
return _pluginDataPath
}
2021-12-22 01:38:22 +00:00
private set(value) {
_pluginDataPath = value
}
2021-12-21 00:58:22 +00:00
override fun onEnable() {
2021-12-23 22:44:02 +00:00
// Create core plugin directory.
pluginDataPath = dataFolder.toPath()
pluginDataPath.toFile().mkdir()
2021-12-21 00:58:22 +00:00
2021-12-23 22:44:02 +00:00
super.onEnable()
2021-12-21 00:58:22 +00:00
}
override fun createFeatures() = listOf(
2021-12-24 08:38:57 +00:00
SchedulerFeature(),
PersistenceFeature(),
BackupFeature(),
DevFeature(),
2022-01-13 06:02:21 +00:00
GameplayFeature(),
PlayerFeature(),
StatsFeature(),
UpdateFeature(),
WorldFeature(),
)
override fun createModule() = module {
single { this@FoundationCorePlugin }
}
}