2023-01-24 21:37:24 -08:00
|
|
|
package gay.pizza.foundation.core
|
2021-12-21 00:58:22 +00:00
|
|
|
|
2023-02-05 19:37:59 -08: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
|
2021-12-21 09:07:10 +00:00
|
|
|
import java.nio.file.Path
|
2021-12-21 00:58:22 +00:00
|
|
|
|
2023-02-05 19:37:59 -08:00
|
|
|
@PluginMainClass
|
2021-12-23 22:44:02 +00:00
|
|
|
class FoundationCorePlugin : FoundationPlugin() {
|
2021-12-21 09:07:10 +00:00
|
|
|
private lateinit var _pluginDataPath: Path
|
|
|
|
|
|
|
|
var pluginDataPath: Path
|
|
|
|
/**
|
|
|
|
* Data path of the core plugin.
|
2023-02-05 19:37:59 -08:00
|
|
|
* Can be used as a check of sorts for dependencies to be sure the plugin is loaded.
|
2021-12-21 09:07:10 +00:00
|
|
|
*/
|
|
|
|
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 09:07:10 +00:00
|
|
|
|
2021-12-21 00:58:22 +00:00
|
|
|
override fun onEnable() {
|
2021-12-23 22:44:02 +00:00
|
|
|
// Create core plugin directory.
|
2021-12-21 09:07:10 +00:00
|
|
|
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
|
|
|
}
|
2021-12-23 23:05:29 +00:00
|
|
|
|
|
|
|
override fun createFeatures() = listOf(
|
2021-12-24 08:38:57 +00:00
|
|
|
SchedulerFeature(),
|
2021-12-23 21:26:10 -05:00
|
|
|
PersistenceFeature(),
|
2021-12-23 23:05:29 +00:00
|
|
|
BackupFeature(),
|
|
|
|
DevFeature(),
|
2022-01-13 06:02:21 +00:00
|
|
|
GameplayFeature(),
|
2021-12-23 23:05:29 +00:00
|
|
|
PlayerFeature(),
|
|
|
|
StatsFeature(),
|
|
|
|
UpdateFeature(),
|
|
|
|
WorldFeature(),
|
|
|
|
)
|
|
|
|
|
|
|
|
override fun createModule() = module {
|
|
|
|
single { this@FoundationCorePlugin }
|
|
|
|
}
|
2021-12-22 21:36:52 -05:00
|
|
|
}
|