Skip to content

Commit

Permalink
Add config
Browse files Browse the repository at this point in the history
  • Loading branch information
wtlgo committed Nov 26, 2023
1 parent dcaa75e commit 68eaeca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/dev/mikchan/mcnp/motd/config/config/IConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ package dev.mikchan.mcnp.motd.config.config

interface IConfig {
fun reload(): Boolean

var enabled: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ internal class BoostedYamlConfig(document: File, resource: InputStream) : IConfi
GeneralSettings.builder().setSerializer(SpigotSerializer.getInstance()).build(),
LoaderSettings.builder().setAutoUpdate(true).build(),
DumperSettings.DEFAULT,
UpdaterSettings.builder().setVersioning(BasicVersioning("configVersion")).build(),
UpdaterSettings.builder().setVersioning(BasicVersioning("config-version")).build(),
)

override fun reload(): Boolean {
return config.reload()
}

override var enabled: Boolean
get() = config.getBoolean("enabled", false)
set(value) {
config.set("enabled", value)
config.save()
}
}
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is an automatic property, do not touch
config-version: 1

enabled: false

0 comments on commit 68eaeca

Please sign in to comment.