diff --git a/src/main/java/dev/mikchan/mcnp/motd/config/config/IConfig.kt b/src/main/java/dev/mikchan/mcnp/motd/config/config/IConfig.kt index fca3a29..97e4615 100644 --- a/src/main/java/dev/mikchan/mcnp/motd/config/config/IConfig.kt +++ b/src/main/java/dev/mikchan/mcnp/motd/config/config/IConfig.kt @@ -4,4 +4,6 @@ interface IConfig { fun reload(): Boolean var enabled: Boolean + var randomImages: Boolean + var motd: List } diff --git a/src/main/java/dev/mikchan/mcnp/motd/config/config/IMOTDConfig.kt b/src/main/java/dev/mikchan/mcnp/motd/config/config/IMOTDConfig.kt new file mode 100644 index 0000000..1ae8188 --- /dev/null +++ b/src/main/java/dev/mikchan/mcnp/motd/config/config/IMOTDConfig.kt @@ -0,0 +1,7 @@ +package dev.mikchan.mcnp.motd.config.config + +interface IMOTDConfig { + val firstLine: String? + val secondLine: String? + val image: String? +} diff --git a/src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlConfig.kt b/src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlConfig.kt index 1e40309..92b38b7 100644 --- a/src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlConfig.kt +++ b/src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlConfig.kt @@ -8,6 +8,7 @@ import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings import dev.dejvokep.boostedyaml.spigot.SpigotSerializer import dev.mikchan.mcnp.motd.config.config.IConfig +import dev.mikchan.mcnp.motd.config.config.IMOTDConfig import java.io.File import java.io.InputStream @@ -31,4 +32,22 @@ internal class BoostedYamlConfig(document: File, resource: InputStream) : IConfi config.set("enabled", value) config.save() } + + override var randomImages: Boolean + get() = config.getBoolean("random-images", false) + set(value) { + config.set("random-images", value) + config.save() + } + override var motd: List + get() = config.getMapList("motd", listOf()).filterNotNull().map { BoostedYamlProxyMOTDConfig(it) } + set(value) { + config.set("motd", value.map { + mapOf( + "first-line" to it.firstLine, + "second-line" to it.secondLine, + "image" to it.image, + ).filter { m -> m.value != null } + }) + } } diff --git a/src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlProxyMOTDConfig.kt b/src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlProxyMOTDConfig.kt new file mode 100644 index 0000000..b44deb1 --- /dev/null +++ b/src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlProxyMOTDConfig.kt @@ -0,0 +1,14 @@ +package dev.mikchan.mcnp.motd.config.config.boostedYaml + +import dev.mikchan.mcnp.motd.config.config.IMOTDConfig + +internal class BoostedYamlProxyMOTDConfig(private val motd: Map<*, *>) : IMOTDConfig { + override val firstLine: String? + get() = motd["first-line"] as? String + + override val secondLine: String? + get() = motd["second-line"] as? String + + override val image: String? + get() = motd["image"] as? String +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 278db76..6380212 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,3 +2,8 @@ config-version: 1 enabled: false +random-images: false +motd: + - first-line: Minecraft + second-line: Server + image: image.png