forked from Upstream/mmocore
Exp table item claims are now properly saved
This commit is contained in:
parent
16651dfe99
commit
9d34d4d655
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.manager.data.mysql;
|
|||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||||
@ -63,6 +64,11 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
|||||||
if (!isEmpty(result.getString("class")))
|
if (!isEmpty(result.getString("class")))
|
||||||
data.setClass(MMOCore.plugin.classManager.get(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()) {
|
if (!data.hasUsedTemporaryData()) {
|
||||||
data.setMana(data.getStats().getStat(StatType.MAX_MANA));
|
data.setMana(data.getStats().getStat(StatType.MAX_MANA));
|
||||||
data.setStamina(data.getStats().getStat(StatType.MAX_STAMINA));
|
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.updateJSONArray("bound_skills", data.getBoundSkills().stream().map(skill -> skill.getSkill().getHandler().getId()).collect(Collectors.toList()));
|
||||||
|
|
||||||
sql.updateJSONObject("skills", data.mapSkillLevels().entrySet());
|
sql.updateJSONObject("skills", data.mapSkillLevels().entrySet());
|
||||||
|
sql.updateJSONObject("times_claimed", data.getItemClaims().entrySet());
|
||||||
|
|
||||||
sql.updateData("attributes", data.getAttributes().toJsonString());
|
sql.updateData("attributes", data.getAttributes().toJsonString());
|
||||||
sql.updateData("professions", data.getCollectionSkills().toJsonString());
|
sql.updateData("professions", data.getCollectionSkills().toJsonString());
|
||||||
|
@ -68,6 +68,10 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
|||||||
if (data.getProfess().hasSkill(id))
|
if (data.getProfess().hasSkill(id))
|
||||||
data.getBoundSkills().add(data.getProfess().getSkill(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.
|
// Load class slots, use try so the player can log in.
|
||||||
if (config.contains("class-info"))
|
if (config.contains("class-info"))
|
||||||
for (String key : config.getConfigurationSection("class-info").getKeys(false))
|
for (String key : config.getConfigurationSection("class-info").getKeys(false))
|
||||||
@ -102,6 +106,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
|||||||
|
|
||||||
config.set("skill", null);
|
config.set("skill", null);
|
||||||
data.mapSkillLevels().forEach((key1, value) -> config.set("skill." + key1, value));
|
data.mapSkillLevels().forEach((key1, value) -> config.set("skill." + key1, value));
|
||||||
|
data.getItemClaims().forEach((key, times) -> config.set("times-claimed." + key, times));
|
||||||
|
|
||||||
List<String> boundSkills = new ArrayList<>();
|
List<String> boundSkills = new ArrayList<>();
|
||||||
data.getBoundSkills().forEach(skill -> boundSkills.add(skill.getSkill().getHandler().getId()));
|
data.getBoundSkills().forEach(skill -> boundSkills.add(skill.getSkill().getHandler().getId()));
|
||||||
|
Loading…
Reference in New Issue
Block a user