-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.mikchan.mcnp.motd | ||
|
||
import dev.mikchan.mcnp.motd.config.creator.IConfigCreator | ||
import dev.mikchan.mcnp.motd.config.creator.boostedYaml.BoostedYamlConfigCreator | ||
|
||
object Creators { | ||
var config: IConfigCreator = BoostedYamlConfigCreator() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package dev.mikchan.mcnp.motd.config.config | ||
|
||
interface IConfig { | ||
fun reload(): Boolean | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/dev/mikchan/mcnp/motd/config/config/boostedYaml/BoostedYamlConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package dev.mikchan.mcnp.motd.config.config.boostedYaml | ||
|
||
import dev.dejvokep.boostedyaml.YamlDocument | ||
import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning | ||
import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings | ||
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings | ||
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 java.io.File | ||
import java.io.InputStream | ||
|
||
internal class BoostedYamlConfig(document: File, resource: InputStream) : IConfig { | ||
private val config: YamlDocument = YamlDocument.create( | ||
document, | ||
resource, | ||
GeneralSettings.builder().setSerializer(SpigotSerializer.getInstance()).build(), | ||
LoaderSettings.builder().setAutoUpdate(true).build(), | ||
DumperSettings.DEFAULT, | ||
UpdaterSettings.builder().setVersioning(BasicVersioning("configVersion")).build(), | ||
) | ||
|
||
override fun reload(): Boolean { | ||
return config.reload() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/dev/mikchan/mcnp/motd/config/creator/IConfigCreator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.mikchan.mcnp.motd.config.creator | ||
|
||
import dev.mikchan.mcnp.motd.MotdPlugin | ||
import dev.mikchan.mcnp.motd.config.config.IConfig | ||
|
||
interface IConfigCreator { | ||
fun build(plugin: MotdPlugin): IConfig | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/dev/mikchan/mcnp/motd/config/creator/boostedYaml/BoostedYamlConfigCreator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.mikchan.mcnp.motd.config.creator.boostedYaml | ||
|
||
import dev.mikchan.mcnp.motd.MotdPlugin | ||
import dev.mikchan.mcnp.motd.config.config.IConfig | ||
import dev.mikchan.mcnp.motd.config.config.boostedYaml.BoostedYamlConfig | ||
import dev.mikchan.mcnp.motd.config.creator.IConfigCreator | ||
import java.io.File | ||
|
||
internal class BoostedYamlConfigCreator : IConfigCreator { | ||
override fun build(plugin: MotdPlugin): IConfig { | ||
val resource = plugin.getResource("config.yml")!! | ||
val document = File(plugin.dataFolder, "config.yml") | ||
return BoostedYamlConfig(document, resource) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ load: STARTUP | |
|
||
libraries: | ||
- org.jetbrains.kotlin:kotlin-stdlib:1.9.21 | ||
- dev.dejvokep:boosted-yaml-spigot:1.4 |