mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2024-11-28 12:35:38 +01:00
Config autoupdate
This commit is contained in:
parent
6ea5479b26
commit
0674b36fbf
@ -2,6 +2,7 @@ package com.artillexstudios.axminions.api.minions.miniontype
|
||||
|
||||
import com.artillexstudios.axapi.config.Config
|
||||
import com.artillexstudios.axapi.libs.boostedyaml.boostedyaml.block.implementation.Section
|
||||
import com.artillexstudios.axapi.libs.boostedyaml.boostedyaml.dvs.versioning.BasicVersioning
|
||||
import com.artillexstudios.axapi.libs.boostedyaml.boostedyaml.settings.dumper.DumperSettings
|
||||
import com.artillexstudios.axapi.libs.boostedyaml.boostedyaml.settings.general.GeneralSettings
|
||||
import com.artillexstudios.axapi.libs.boostedyaml.boostedyaml.settings.loader.LoaderSettings
|
||||
@ -16,18 +17,31 @@ import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.persistence.PersistentDataType
|
||||
|
||||
abstract class MinionType(private val name: String, private val defaults: InputStream) {
|
||||
abstract class MinionType(private val name: String, private val defaults: InputStream, private val autoUpdateConfig: Boolean) {
|
||||
private lateinit var config: Config
|
||||
|
||||
constructor(name: String, defaults: InputStream) : this(name, defaults, false)
|
||||
|
||||
fun load() {
|
||||
config = Config(
|
||||
File(AxMinionsAPI.INSTANCE.getAxMinionsDataFolder(), "/minions/$name.yml"),
|
||||
defaults,
|
||||
GeneralSettings.builder().setUseDefaults(false).build(),
|
||||
LoaderSettings.DEFAULT,
|
||||
DumperSettings.DEFAULT,
|
||||
UpdaterSettings.DEFAULT
|
||||
)
|
||||
if (!autoUpdateConfig) {
|
||||
config = Config(
|
||||
File(AxMinionsAPI.INSTANCE.getAxMinionsDataFolder(), "/minions/$name.yml"),
|
||||
defaults,
|
||||
GeneralSettings.builder().setUseDefaults(false).build(),
|
||||
LoaderSettings.DEFAULT,
|
||||
DumperSettings.DEFAULT,
|
||||
UpdaterSettings.DEFAULT
|
||||
)
|
||||
} else {
|
||||
config = Config(
|
||||
File(AxMinionsAPI.INSTANCE.getAxMinionsDataFolder(), "/minions/$name.yml"),
|
||||
defaults,
|
||||
GeneralSettings.builder().setUseDefaults(false).build(),
|
||||
LoaderSettings.builder().setAutoUpdate(true).build(),
|
||||
DumperSettings.DEFAULT,
|
||||
UpdaterSettings.builder().setVersioning(BasicVersioning("config-version")).build()
|
||||
)
|
||||
}
|
||||
AxMinionsAPI.INSTANCE.getDataHandler().insertType(this)
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.inventory.FurnaceRecipe
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource("minions/miner.yml")!!) {
|
||||
class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource("minions/miner.yml")!!, true) {
|
||||
companion object {
|
||||
private var asyncExecutor: ExecutorService? = null
|
||||
private val smeltingRecipes = ArrayList<FurnaceRecipe>()
|
||||
|
@ -156,4 +156,6 @@ upgrades:
|
||||
boots:
|
||||
type: LEATHER_BOOTS
|
||||
color: "150, 150, 150"
|
||||
glow: true
|
||||
glow: true
|
||||
|
||||
config-version: 1
|
Loading…
Reference in New Issue
Block a user