diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java index 1d09f87a..df083d7a 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.manager.data.mysql; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.OfflinePlayerData; @@ -63,6 +64,11 @@ public class MySQLPlayerDataManager extends PlayerDataManager { if (!isEmpty(result.getString("class"))) data.setClass(MMOCore.plugin.classManager.get(result.getString("class"))); + if (!isEmpty(result.getString("times_claimed"))) { + JsonObject json = new JsonParser().parse(result.getString("times_claimed")).getAsJsonObject(); + json.entrySet().forEach(entry -> data.getItemClaims().put(entry.getKey(), entry.getValue().getAsInt())); + } + if (!data.hasUsedTemporaryData()) { data.setMana(data.getStats().getStat(StatType.MAX_MANA)); data.setStamina(data.getStats().getStat(StatType.MAX_STAMINA)); @@ -137,6 +143,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager { sql.updateJSONArray("bound_skills", data.getBoundSkills().stream().map(skill -> skill.getSkill().getHandler().getId()).collect(Collectors.toList())); sql.updateJSONObject("skills", data.mapSkillLevels().entrySet()); + sql.updateJSONObject("times_claimed", data.getItemClaims().entrySet()); sql.updateData("attributes", data.getAttributes().toJsonString()); sql.updateData("professions", data.getCollectionSkills().toJsonString()); diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java index d4f64dc7..7efe48fa 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java @@ -68,6 +68,10 @@ public class YAMLPlayerDataManager extends PlayerDataManager { if (data.getProfess().hasSkill(id)) data.getBoundSkills().add(data.getProfess().getSkill(id)); + if (config.contains("times-claimed")) + for (String key : config.getConfigurationSection("times-claimed").getKeys(true)) + data.getItemClaims().put(key, config.getInt("times-claimed." + key)); + // Load class slots, use try so the player can log in. if (config.contains("class-info")) for (String key : config.getConfigurationSection("class-info").getKeys(false)) @@ -102,6 +106,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager { config.set("skill", null); data.mapSkillLevels().forEach((key1, value) -> config.set("skill." + key1, value)); + data.getItemClaims().forEach((key, times) -> config.set("times-claimed." + key, times)); List boundSkills = new ArrayList<>(); data.getBoundSkills().forEach(skill -> boundSkills.add(skill.getSkill().getHandler().getId()));