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 a64557e..afdaaa6 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 @@ -5,6 +5,7 @@ interface IConfig { var enabled: Boolean var randomImages: Boolean + var mixMotd: Boolean var motd: List var personalizedMotd: List } 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 942f614..5b73b95 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 @@ -39,6 +39,14 @@ internal class BoostedYamlConfig(document: File, resource: InputStream) : IConfi config.set("random-images", value) config.save() } + + override var mixMotd: Boolean + get() = config.getBoolean("mix-motd", false) + set(value) { + config.set("mix-motd", value) + config.save() + } + override var motd: List get() = config.getMapList("motd", listOf()).filterNotNull().map { BoostedYamlProxyMOTDConfig(it) } set(value) { diff --git a/src/main/java/dev/mikchan/mcnp/motd/motd/manager/MOTDManager.kt b/src/main/java/dev/mikchan/mcnp/motd/motd/manager/MOTDManager.kt index 004600f..2043426 100644 --- a/src/main/java/dev/mikchan/mcnp/motd/motd/manager/MOTDManager.kt +++ b/src/main/java/dev/mikchan/mcnp/motd/motd/manager/MOTDManager.kt @@ -4,7 +4,14 @@ import dev.mikchan.mcnp.motd.MOTDPlugin internal class MOTDManager(private val plugin: MOTDPlugin) : IMOTDManager { override fun getRandom(personalized: Boolean): IMOTD? { - val motd = if (personalized) plugin.config.motd + plugin.config.personalizedMotd else plugin.config.motd + val motd = if (!personalized) { + plugin.config.motd + } else if (plugin.config.mixMotd) { + plugin.config.motd + plugin.config.personalizedMotd + } else { + plugin.config.personalizedMotd + } + return motd.ifEmpty { null }?.random()?.let { MOTDProxy(it, plugin.imageManager) } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 81c7318..a7e42c8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,10 +3,12 @@ config-version: 1 enabled: false random-images: false +mix-motd: false + motd: - first-line: Minecraft second-line: Server - image: image.png + image: image personalized-motd: - first-line: Minecraft Server