diff --git a/geary-papermc-core/src/main/kotlin/com/mineinabyss/geary/papermc/GearyProductionPaperConfigModule.kt b/geary-papermc-core/src/main/kotlin/com/mineinabyss/geary/papermc/GearyProductionPaperConfigModule.kt index ff8f09d..8006614 100644 --- a/geary-papermc-core/src/main/kotlin/com/mineinabyss/geary/papermc/GearyProductionPaperConfigModule.kt +++ b/geary-papermc-core/src/main/kotlin/com/mineinabyss/geary/papermc/GearyProductionPaperConfigModule.kt @@ -1,13 +1,21 @@ package com.mineinabyss.geary.papermc import com.mineinabyss.idofront.config.config +import com.mineinabyss.idofront.messaging.ComponentLogger +import com.mineinabyss.idofront.messaging.injectLogger import com.mineinabyss.idofront.messaging.observeLogger +import com.mineinabyss.idofront.plugin.dataPath import org.bukkit.plugin.java.JavaPlugin class GearyProductionPaperConfigModule( override val plugin: JavaPlugin, ) : GearyPaperConfigModule { - override val configHolder = config("config", plugin.dataFolder.toPath(), GearyPaperConfig()) + override val configHolder = config( + "config", plugin.dataPath, GearyPaperConfig(), + onLoad = { + plugin.injectLogger(ComponentLogger.forPlugin(plugin, minSeverity = it.logLevel)) + } + ) override val config: GearyPaperConfig by configHolder diff --git a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt index 4b7d52a..fb93fc9 100644 --- a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt +++ b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/PaperEngineModule.kt @@ -10,28 +10,17 @@ import com.mineinabyss.geary.engine.archetypes.operations.ArchetypeReadOperation import com.mineinabyss.geary.modules.ArchetypeEngineModule import com.mineinabyss.geary.modules.GearyModuleProvider import com.mineinabyss.geary.papermc.Catching.Companion.asyncCheck -import com.mineinabyss.geary.papermc.GearyPaperConfig import com.mineinabyss.geary.papermc.GearyPlugin import com.mineinabyss.geary.papermc.gearyPaper import com.mineinabyss.idofront.di.DI -import com.mineinabyss.idofront.messaging.ComponentLogger -import com.mineinabyss.idofront.messaging.injectLogger +import com.mineinabyss.idofront.messaging.observeLogger import com.mineinabyss.idofront.time.ticks -class ConfigBased( - config: GearyPaperConfig, - plugin: GearyPlugin, -) { - val logger = ComponentLogger.forPlugin(plugin, minSeverity = config.logLevel) -} - class PaperEngineModule( val plugin: GearyPlugin ) : ArchetypeEngineModule(tickDuration = 1.ticks) { - private var configBased = updateToMatch(gearyPaper.config) - override val engine: ArchetypeEngine = PaperMCEngine() - override val logger get() = configBased.logger + override val logger by plugin.observeLogger() override val entityProvider: EntityByArchetypeProvider get() { @@ -64,13 +53,6 @@ class PaperEngineModule( return super.archetypeProvider } - fun updateToMatch(config: GearyPaperConfig): ConfigBased { - val configBased = ConfigBased(config, plugin) - this.configBased = configBased - plugin.injectLogger(logger) - return configBased - } - companion object : GearyModuleProvider { override fun start(module: PaperEngineModule) { DI.add(module) diff --git a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/commands/GearyReloadCommand.kt b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/commands/GearyReloadCommand.kt index eb8126a..68422c9 100644 --- a/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/commands/GearyReloadCommand.kt +++ b/geary-papermc-plugin/src/main/kotlin/com/mineinabyss/geary/papermc/plugin/commands/GearyReloadCommand.kt @@ -1,10 +1,8 @@ package com.mineinabyss.geary.papermc.plugin.commands import com.mineinabyss.geary.papermc.gearyPaper -import com.mineinabyss.geary.papermc.plugin.PaperEngineModule import com.mineinabyss.geary.prefabs.prefabs import com.mineinabyss.idofront.commands.Command -import com.mineinabyss.idofront.di.DI private val prefabLoader get() = prefabs.loader @@ -12,7 +10,6 @@ fun Command.reload() { "reload" { action { gearyPaper.configHolder.reload() - DI.get().updateToMatch(gearyPaper.config) prefabLoader.loadOrUpdatePrefabs() } } diff --git a/gradle.properties b/gradle.properties index 01610c7..c3fc3f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ kotlin.code.style=official group=com.mineinabyss version=0.29 -idofrontVersion=0.23.0-dev.7 +idofrontVersion=0.23.0-dev.10 gearyVersion=0.26.0-dev.3