Skip to content

Commit

Permalink
paper config stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
powercasgamer committed Dec 2, 2023
1 parent ad79280 commit 0dc09c3
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions paper/src/main/kotlin/dev/mizule/timetriggeredperms/paper/TTP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package dev.mizule.timetriggeredperms.paper

import dev.mizule.timetriggeredperms.core.TTPPlugin
import dev.mizule.timetriggeredperms.core.config.Config
import dev.mizule.timetriggeredperms.core.config.ConfigManager
import dev.mizule.timetriggeredperms.paper.command.ReloadCommand
import dev.mizule.timetriggeredperms.paper.listener.LuckPermsListener
import org.bstats.bukkit.Metrics
Expand All @@ -38,31 +39,13 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader

class TTP : JavaPlugin(), TTPPlugin<JavaPlugin> {

private val configPath = dataFolder.resolve("permissions.yml")
private val configPath = dataFolder.resolve("permissions.yml").toPath()
private val pluginId = 20404

val configLoader = YamlConfigurationLoader.builder()
.file(configPath)
.nodeStyle(NodeStyle.BLOCK)
.indent(2)
.defaultOptions { options ->
options.shouldCopyDefaults(true)
options.serializers { builder ->
builder.registerAnnotatedObjects(objectMapperFactory())
}
}
.build()

var configNode = configLoader.load()
var config = requireNotNull(configNode.get<Config>()) {
"Could not read configuration"
}
private lateinit var config: Config

override fun onEnable() {
if (!configPath.exists()) {
configNode.set(config) // update the backing node to add defaults
configLoader.save(configNode)
}
this.config = ConfigManager.loadConfig(configPath)
Metrics(this, pluginId)
LuckPermsListener(this)

Expand Down

0 comments on commit 0dc09c3

Please sign in to comment.