From d84b07edfbd5b6affe3db69c31e8b548f78f9efd Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 3 Nov 2021 19:05:10 +0000 Subject: [PATCH] Updated to new eco storage system --- .../com/willfp/ecoskills/EcoSkillsPlugin.java | 21 +--- .../com/willfp/ecoskills/EcoSkillsPlayer.kt | 18 +-- .../com/willfp/ecoskills/data/DataListener.kt | 7 -- .../com/willfp/ecoskills/data/SaveHandler.kt | 32 ----- .../data/{storage => legacy}/DataHandler.kt | 5 +- .../data/legacy/LegacyPlayerProfile.kt | 110 +++++++++++++++++ .../{storage => legacy}/MySQLDataHandler.kt | 24 +--- .../{storage => legacy}/YamlDataHandler.kt | 10 +- .../ecoskills/data/storage/PlayerProfile.kt | 112 ------------------ .../com/willfp/ecoskills/effects/Effect.kt | 7 ++ .../com/willfp/ecoskills/skills/Skill.kt | 13 +- .../kotlin/com/willfp/ecoskills/stats/Stat.kt | 7 ++ .../core-plugin/src/main/resources/config.yml | 5 + .../core-plugin/src/main/resources/data.yml | 2 +- 14 files changed, 161 insertions(+), 212 deletions(-) delete mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/SaveHandler.kt rename eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/{storage => legacy}/DataHandler.kt (65%) create mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/LegacyPlayerProfile.kt rename eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/{storage => legacy}/MySQLDataHandler.kt (73%) rename eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/{storage => legacy}/YamlDataHandler.kt (69%) delete mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/PlayerProfile.kt diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java index b212589..74a532b 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/EcoSkillsPlugin.java @@ -8,10 +8,10 @@ import com.willfp.ecoskills.commands.CommandSkills; import com.willfp.ecoskills.config.EffectsYml; import com.willfp.ecoskills.data.DataListener; import com.willfp.ecoskills.data.LeaderboardHandler; -import com.willfp.ecoskills.data.SaveHandler; -import com.willfp.ecoskills.data.storage.DataHandler; -import com.willfp.ecoskills.data.storage.MySQLDataHandler; -import com.willfp.ecoskills.data.storage.YamlDataHandler; +import com.willfp.ecoskills.data.legacy.DataHandler; +import com.willfp.ecoskills.data.legacy.LegacyPlayerProfile; +import com.willfp.ecoskills.data.legacy.MySQLDataHandler; +import com.willfp.ecoskills.data.legacy.YamlDataHandler; import com.willfp.ecoskills.effects.Effect; import com.willfp.ecoskills.effects.Effects; import com.willfp.ecoskills.integrations.EcoEnchantsEnchantingLeveller; @@ -53,6 +53,8 @@ public class EcoSkillsPlugin extends EcoPlugin { effectsYml = new EffectsYml(this); dataHandler = this.getConfigYml().getBool("mysql.enabled") ? new MySQLDataHandler(this) : new YamlDataHandler(this); + + LegacyPlayerProfile.Companion.migrateAll(); } @Override @@ -69,21 +71,10 @@ public class EcoSkillsPlugin extends EcoPlugin { this.getEventManager().unregisterListener(skill); this.getEventManager().registerListener(skill); } - SaveHandler.Companion.save(this); - this.getScheduler().runTimer( - new SaveHandler.Runnable(this), - this.getConfigYml().getInt("autosave.ticks"), - this.getConfigYml().getInt("autosave.ticks") - ); this.getScheduler().runTimer(new LeaderboardHandler.Runnable(), 50, 2400); } - @Override - protected void handleDisable() { - SaveHandler.Companion.save(this); - } - /** * Get data handler. * diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt index 4d7f094..6bb2239 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt @@ -1,8 +1,8 @@ package com.willfp.ecoskills +import com.willfp.eco.core.data.PlayerProfile import com.willfp.ecoskills.api.PlayerSkillExpGainEvent import com.willfp.ecoskills.api.PlayerSkillLevelUpEvent -import com.willfp.ecoskills.data.storage.PlayerProfile.Companion.profile import com.willfp.ecoskills.effects.Effect import com.willfp.ecoskills.skills.Skill import com.willfp.ecoskills.skills.Skills @@ -95,11 +95,11 @@ fun Player.giveSkillExperience(skill: Skill, experience: Double, noMultiply: Boo } fun OfflinePlayer.getSkillLevel(skill: Skill): Int { - return profile.read(skill.id, 0) + return PlayerProfile.load(this).read(skill.dataKey) } fun OfflinePlayer.setSkillLevel(skill: Skill, level: Int) { - profile.write(skill.id, level) + PlayerProfile.load(this).write(skill.dataKey, level) } fun OfflinePlayer.getSkillProgressToNextLevel(skill: Skill): Double { @@ -111,19 +111,19 @@ fun OfflinePlayer.getSkillProgressRequired(skill: Skill): Int { } fun OfflinePlayer.getSkillProgress(skill: Skill): Double { - return profile.read(skill.xpKey.key, 0.0) + return PlayerProfile.load(this).read(skill.dataXPKey) } fun OfflinePlayer.setSkillProgress(skill: Skill, level: Double) { - profile.write(skill.xpKey.key, level) + PlayerProfile.load(this).write(skill.dataXPKey, level) } fun OfflinePlayer.getEffectLevel(effect: Effect): Int { - return profile.read(effect.id, 0) + return PlayerProfile.load(this).read(effect.dataKey) } fun OfflinePlayer.setEffectLevel(effect: Effect, level: Int) { - profile.write(effect.id, level) + PlayerProfile.load(this).write(effect.dataKey, level) } fun OfflinePlayer.getStatLevel(stat: Stat): Int { @@ -145,11 +145,11 @@ fun Player.getBonusStatLevel(stat: Stat): Int { } fun OfflinePlayer.getBaseStatLevel(stat: Stat): Int { - return profile.read(stat.id, 0) + return PlayerProfile.load(this).read(stat.dataKey) } fun Player.setStatLevel(stat: Stat, level: Int) { - profile.write(stat.id, level) + PlayerProfile.load(this).write(stat.dataKey, level) stat.updateStatLevel(this) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/DataListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/DataListener.kt index 9f28265..66c9079 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/DataListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/DataListener.kt @@ -1,6 +1,5 @@ package com.willfp.ecoskills.data -import com.willfp.ecoskills.data.storage.PlayerProfile import com.willfp.ecoskills.effects.Effect import com.willfp.ecoskills.effects.Effects import com.willfp.ecoskills.getSkillLevel @@ -11,7 +10,6 @@ import org.bukkit.attribute.Attribute import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.player.PlayerJoinEvent -import org.bukkit.event.player.PlayerQuitEvent class DataListener : Listener { @EventHandler @@ -55,9 +53,4 @@ class DataListener : Listener { stat.updateStatLevel(event.player) } } - - @EventHandler - fun onLeave(event: PlayerQuitEvent) { - PlayerProfile.savePlayer(event.player.uniqueId) - } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/SaveHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/SaveHandler.kt deleted file mode 100644 index 0e73360..0000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/SaveHandler.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.willfp.ecoskills.data - -import com.willfp.ecoskills.EcoSkillsPlugin -import com.willfp.ecoskills.data.storage.PlayerProfile -import com.willfp.ecoskills.expMultiplierCache -import org.bukkit.Bukkit - -class SaveHandler { - companion object { - fun save(plugin: EcoSkillsPlugin) { - if (Bukkit.getOnlinePlayers().isEmpty()) { - return - } - if (plugin.configYml.getBool("autosave.log")) { - plugin.logger.info("Auto-Saving player data!") - } - PlayerProfile.saveAll(plugin.configYml.getBool("autosave.async")) - expMultiplierCache.clear() - if (plugin.configYml.getBool("autosave.log")) { - plugin.logger.info("Saved data!") - } - } - } - - class Runnable( - private val plugin: EcoSkillsPlugin - ) : java.lang.Runnable { - override fun run() { - save(plugin) - } - } -} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/DataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/DataHandler.kt similarity index 65% rename from eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/DataHandler.kt rename to eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/DataHandler.kt index 590ede7..d571124 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/DataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/DataHandler.kt @@ -1,11 +1,8 @@ -package com.willfp.ecoskills.data.storage +package com.willfp.ecoskills.data.legacy import java.util.* interface DataHandler { - fun save() - - fun write(uuid: UUID, key: String, value: T) fun read(uuid: UUID, key: String): T? fun read(uuid: UUID, key: String, default: T): T { return read(uuid, key) ?: default diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/LegacyPlayerProfile.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/LegacyPlayerProfile.kt new file mode 100644 index 0000000..943ec77 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/LegacyPlayerProfile.kt @@ -0,0 +1,110 @@ +package com.willfp.ecoskills.data.legacy + +import com.willfp.eco.core.data.PlayerProfile +import com.willfp.eco.core.data.keys.PersistentDataKey +import com.willfp.ecoskills.EcoSkillsPlugin +import com.willfp.ecoskills.effects.Effects +import com.willfp.ecoskills.plugin +import com.willfp.ecoskills.skills.Skills +import com.willfp.ecoskills.stats.Stats +import org.bukkit.Bukkit +import org.bukkit.OfflinePlayer +import java.util.* + +@Suppress("UNCHECKED_CAST", "DEPRECATED") +class LegacyPlayerProfile private constructor( + private val data: MutableMap +) { + private fun read(key: String, default: T): T { + return data[key] as T? ?: default + } + + companion object { + private val handler = EcoSkillsPlugin.getInstance().dataHandler + private val loaded = mutableMapOf() + private val keys = mutableMapOf() + private val mappedKeys = mutableMapOf>() + + private fun load(uuid: UUID): LegacyPlayerProfile { + val found = loaded[uuid] + if (found != null) { + return found + } + + val data = mutableMapOf() + for ((key, type) in keys) { + when (type) { + Type.INT -> data[key] = handler.read(uuid, key, 0) + Type.DOUBLE -> data[key] = handler.read(uuid, key, 0.0) + } + } + + val profile = LegacyPlayerProfile(data) + loaded[uuid] = profile + return profile + } + + fun migrateAll() { + if (plugin.configYml.getBool("mysql.migrated")) { + return + } + plugin.logger.info("-----------------------------------------") + plugin.logger.info("Migrating player data! (Automatic)") + plugin.logger.info("This will only run once, ever - not every time your server starts up") + plugin.logger.info("so there's no need to worry about how long it takes. Once this is complete,") + plugin.logger.info("feel free to delete data.yml as it won't be used anymore") + plugin.logger.info("-----------------------------------------") + for (offlinePlayer in Bukkit.getServer().offlinePlayers) { + plugin.logger.info("Migrating player ${offlinePlayer.uniqueId}...") + migrate(offlinePlayer) + } + plugin.logger.info("Migration complete!") + plugin.configYml.set("mysql.migrated", true) + } + + private fun migrate(player: OfflinePlayer) { + fun writeKey(profile: PlayerProfile, key: PersistentDataKey, value: Any) { + value as T + profile.write(key, value) + } + + val ecoProfile = PlayerProfile.load(player) + + for ((key, type) in keys) { + val value = load(player.uniqueId).read( + key, when (type) { + Type.INT -> 0 + Type.DOUBLE -> 0.0 + } + ) + + val newKey = mappedKeys[key] ?: continue + writeKey(ecoProfile, newKey, value) + } + } + + init { + for (skill in Skills.values()) { + keys[skill.id] = Type.INT + mappedKeys[skill.id] = skill.dataKey + keys[skill.id + "_progress"] = Type.DOUBLE + mappedKeys[skill.id + "_progress"] = skill.dataXPKey + } + + for (stat in Stats.values()) { + keys[stat.id] = Type.INT + mappedKeys[stat.id] = stat.dataKey + } + + for (effect in Effects.values()) { + keys[effect.id] = Type.INT + mappedKeys[effect.id] = effect.dataKey + } + } + } + + private enum class Type { + DOUBLE, + INT + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/MySQLDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/MySQLDataHandler.kt similarity index 73% rename from eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/MySQLDataHandler.kt rename to eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/MySQLDataHandler.kt index 4d42ba9..8ea8950 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/MySQLDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/MySQLDataHandler.kt @@ -1,4 +1,4 @@ -package com.willfp.ecoskills.data.storage +package com.willfp.ecoskills.data.legacy import com.willfp.ecoskills.EcoSkillsPlugin import com.willfp.ecoskills.effects.Effects @@ -30,7 +30,7 @@ class MySQLDataHandler( for (skill in Skills.values()) { registerColumn(skill.id, IntegerColumnType()) .default(0) - registerColumn(skill.xpKey.key, DoubleColumnType()) + registerColumn(skill.id + "_progress", DoubleColumnType()) .default(0.0) } @@ -49,24 +49,6 @@ class MySQLDataHandler( } } - override fun save() { - // Do nothing - } - - override fun write(uuid: UUID, key: String, value: T) { - transaction { - Players.select { Players.id eq uuid }.firstOrNull() ?: run { - Players.insert { - it[this.id] = uuid - } - } - val column: Column = Players.columns.stream().filter { it.name == key }.findFirst().get() as Column - Players.update({ Players.id eq uuid }) { - it[column] = value - } - } - } - override fun read(uuid: UUID, key: String): T? { var value: T? = null transaction { @@ -79,7 +61,5 @@ class MySQLDataHandler( object Players : UUIDTable("EcoSkills_Players") { override val id: Column> = uuid("uuid") .entityId() - val name = varchar("name", 100) - .default("Unknown Player") } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/YamlDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/YamlDataHandler.kt similarity index 69% rename from eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/YamlDataHandler.kt rename to eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/YamlDataHandler.kt index a06a9d1..a6c34d2 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/YamlDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/legacy/YamlDataHandler.kt @@ -1,4 +1,4 @@ -package com.willfp.ecoskills.data.storage +package com.willfp.ecoskills.data.legacy import com.willfp.eco.core.config.yaml.YamlBaseConfig import com.willfp.ecoskills.EcoSkillsPlugin @@ -10,14 +10,6 @@ class YamlDataHandler( ) : DataHandler { private val dataYml = DataYml(plugin) - override fun save() { - dataYml.save() - } - - override fun write(uuid: UUID, key: String, value: T) { - dataYml.set("player.$uuid.$key", value) - } - override fun read(uuid: UUID, key: String): T? { return dataYml.get("player.$uuid.$key") as T? } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/PlayerProfile.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/PlayerProfile.kt deleted file mode 100644 index 5e50cfd..0000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/data/storage/PlayerProfile.kt +++ /dev/null @@ -1,112 +0,0 @@ -package com.willfp.ecoskills.data.storage - -import com.willfp.ecoskills.EcoSkillsPlugin -import com.willfp.ecoskills.effects.Effects -import com.willfp.ecoskills.plugin -import com.willfp.ecoskills.skills.Skills -import com.willfp.ecoskills.stats.Stats -import org.bukkit.OfflinePlayer -import java.util.* - -@Suppress("UNCHECKED_CAST") -class PlayerProfile private constructor( - private val data: MutableMap -) { - fun write(key: String, value: T) { - data[key] = value - } - - fun read(key: String, default: T): T { - return data[key] as T? ?: default - } - - companion object { - private val handler = EcoSkillsPlugin.getInstance().dataHandler - private val loaded = mutableMapOf() - private val keys = mutableMapOf() - - private fun load(uuid: UUID): PlayerProfile { - val found = loaded[uuid] - if (found != null) { - return found - } - - val data = mutableMapOf() - for ((key, type) in keys) { - when (type) { - Type.INT -> data[key] = handler.read(uuid, key, 0) - Type.DOUBLE -> data[key] = handler.read(uuid, key, 0.0) - Type.STRING -> data[key] = handler.read(uuid, key, "Unknown") - } - } - - val profile = PlayerProfile(data) - loaded[uuid] = profile - return profile - } - - fun savePlayer(uuid: UUID) { - writeToHandler(uuid) - saveToHandler() - } - - private fun writeToHandler(uuid: UUID) { - val profile = loaded[uuid] ?: return - for ((key, type) in keys) { - when (type) { - Type.INT -> handler.write(uuid, key, profile.read(key, 0)) - Type.DOUBLE -> handler.write(uuid, key, profile.read(key, 0.0)) - Type.STRING -> handler.write(uuid, key, profile.read(key, "Unknown Value")) - } - } - } - - private fun saveToHandler() { - handler.save() - } - - fun saveAll(async: Boolean) { - val saver = { - for ((uuid, _) in loaded) { - writeToHandler(uuid) - } - - saveToHandler() - } - - if (async) { - plugin.scheduler.runAsync(saver) - } else { - saver.invoke() - } - } - - val OfflinePlayer.profile: PlayerProfile - get() { - return load(this.uniqueId) - } - - init { - keys["name"] = Type.STRING - - for (skill in Skills.values()) { - keys[skill.id] = Type.INT - keys[skill.xpKey.key] = Type.DOUBLE - } - - for (stat in Stats.values()) { - keys[stat.id] = Type.INT - } - - for (effect in Effects.values()) { - keys[effect.id] = Type.INT - } - } - } - - private enum class Type { - STRING, - DOUBLE, - INT - } -} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/Effect.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/Effect.kt index aaa4356..6ff16c0 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/Effect.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/Effect.kt @@ -1,6 +1,8 @@ package com.willfp.ecoskills.effects import com.willfp.eco.core.config.interfaces.Config +import com.willfp.eco.core.data.keys.PersistentDataKey +import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.StringUtils @@ -17,6 +19,11 @@ abstract class Effect( protected val plugin: EcoSkillsPlugin = EcoSkillsPlugin.getInstance() val key: NamespacedKey = plugin.namespacedKeyFactory.create(id) + val dataKey = PersistentDataKey( + plugin.namespacedKeyFactory.create(id), + PersistentDataKeyType.INT, + 0 + ) val uuid: UUID = UUID.nameUUIDFromBytes(id.toByteArray()) lateinit var config: Config diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/skills/Skill.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/skills/Skill.kt index 8461aad..524ce02 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/skills/Skill.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/skills/Skill.kt @@ -2,6 +2,8 @@ package com.willfp.ecoskills.skills import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.config.interfaces.Config +import com.willfp.eco.core.data.keys.PersistentDataKey +import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.StringUtils @@ -21,7 +23,16 @@ abstract class Skill( protected val plugin: EcoPlugin = EcoSkillsPlugin.getInstance() val key: NamespacedKey = plugin.namespacedKeyFactory.create(id) - val xpKey: NamespacedKey = plugin.namespacedKeyFactory.create(id + "_progress") + val dataKey = PersistentDataKey( + plugin.namespacedKeyFactory.create(id), + PersistentDataKeyType.INT, + 0 + ) + val dataXPKey = PersistentDataKey( + plugin.namespacedKeyFactory.create("${id}_xp"), + PersistentDataKeyType.DOUBLE, + 0.0 + ) lateinit var config: Config lateinit var name: String lateinit var description: String diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt index 2040e6d..52dadf5 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt @@ -2,6 +2,8 @@ package com.willfp.ecoskills.stats import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.config.interfaces.Config +import com.willfp.eco.core.data.keys.PersistentDataKey +import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry import com.willfp.eco.util.NumberUtils import com.willfp.ecoskills.* @@ -17,6 +19,11 @@ abstract class Stat( val key: NamespacedKey = plugin.namespacedKeyFactory.create(id) val uuid: UUID = UUID.nameUUIDFromBytes(id.toByteArray()) + val dataKey = PersistentDataKey( + plugin.namespacedKeyFactory.create(id), + PersistentDataKeyType.INT, + 0 + ) lateinit var config: Config lateinit var name: String diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 3e1fff7..d8eeea4 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -3,7 +3,12 @@ # by Auxilor # + +# EcoSkills now uses eco's data storage system, this section will be removed in the future +# This exists purely to be able to migrate player data +# Go to /plugins/eco/config.yml to change MySQL settings mysql: + migrated: false # Internal value - DO NOT CHANGE enabled: false # Set to false, data.yml will be used instead. host: localhost port: 3306 diff --git a/eco-core/core-plugin/src/main/resources/data.yml b/eco-core/core-plugin/src/main/resources/data.yml index 577edeb..496b31e 100644 --- a/eco-core/core-plugin/src/main/resources/data.yml +++ b/eco-core/core-plugin/src/main/resources/data.yml @@ -1 +1 @@ -# Don't edit this file - it's for internal storage only \ No newline at end of file +# This file exists for legacy support, it will be removed in the future \ No newline at end of file