Solved all SQL Bugs

This commit is contained in:
Ka0rX 2022-10-13 08:32:15 +02:00
parent c4198f264c
commit c573c0abd0
3 changed files with 7 additions and 5 deletions

View File

@ -190,7 +190,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
public int getPointSpent(SkillTree skillTree) { public int getPointSpent(SkillTree skillTree) {
return pointSpent.get(skillTree); return pointSpent.getOrDefault(skillTree,0);
} }
@ -199,7 +199,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
} }
public void giveSkillTreePoints(String id, int val) { public void giveSkillTreePoints(String id, int val) {
skillTreePoints.put(id, skillTreePoints.get(id) + val); skillTreePoints.put(id, skillTreePoints.getOrDefault(id,0) + val);
} }
public int countSkillTreePoints(SkillTree skillTree) { public int countSkillTreePoints(SkillTree skillTree) {
@ -296,7 +296,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
} }
public int getNodeLevel(SkillTreeNode node) { public int getNodeLevel(SkillTreeNode node) {
return nodeLevels.get(node); return nodeLevels.getOrDefault(node,0);
} }
public void setNodeLevel(SkillTreeNode node, int nodeLevel) { public void setNodeLevel(SkillTreeNode node, int nodeLevel) {

View File

@ -101,7 +101,8 @@ public class PlayerProfessions {
playerData.getItemClaims().put("profession." + entry.getKey(), entry.getValue().getAsInt()); playerData.getItemClaims().put("profession." + entry.getKey(), entry.getValue().getAsInt());
for (Profession profession : MMOCore.plugin.professionManager.getAll()) { for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
profession.getExperienceTable().claimStatTriggers(playerData, profession); if (profession.hasExperienceTable())
profession.getExperienceTable().claimStatTriggers(playerData, profession);
} }
} }

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmocore.manager.data.mysql; package net.Indyuce.mmocore.manager.data.mysql;
import com.google.gson.Gson;
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 com.google.gson.JsonParser;
@ -110,7 +111,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
if (!isEmpty(result.getString("friends"))) if (!isEmpty(result.getString("friends")))
MMOCoreUtils.jsonArrayToList(result.getString("friends")).forEach(str -> data.getFriends().add(UUID.fromString(str))); MMOCoreUtils.jsonArrayToList(result.getString("friends")).forEach(str -> data.getFriends().add(UUID.fromString(str)));
if (!isEmpty(result.getString("skills"))) { if (!isEmpty(result.getString("skills"))) {
JsonObject object = MythicLib.plugin.getJson().parse(result.getString("skills"), JsonObject.class); JsonObject object=new Gson().fromJson(result.getString("skills"), JsonObject.class);
for (Entry<String, JsonElement> entry : object.entrySet()) for (Entry<String, JsonElement> entry : object.entrySet())
data.setSkillLevel(entry.getKey(), entry.getValue().getAsInt()); data.setSkillLevel(entry.getKey(), entry.getValue().getAsInt());
} }