From 706413e8e80e5b009da8c17a95f35ebb1e35fe9b Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Sun, 16 Oct 2022 21:50:20 +0200 Subject: [PATCH] Modifications in managers to make class based skill tree work. --- .../manager/data/mysql/MySQLPlayerDataManager.java | 13 +++++++++++++ .../manager/data/yaml/YAMLPlayerDataManager.java | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java index 73802d23..3fa1483a 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java @@ -231,6 +231,9 @@ public class MySQLPlayerDataManager extends PlayerDataManager { classinfo.addProperty("skill-points", info.getSkillPoints()); classinfo.addProperty("attribute-points", info.getAttributePoints()); classinfo.addProperty("attribute-realloc-points", info.getAttributeReallocationPoints()); + classinfo.addProperty("skill-reallocation-points",info.getSkillReallocationPoints()); + classinfo.addProperty("skill-tree-reallocation-points",info.getSkillTreeReallocationPoints()); + JsonObject skillinfo = new JsonObject(); for (String skill : info.getSkillKeys()) skillinfo.addProperty(skill, info.getSkillLevel(skill)); @@ -240,6 +243,16 @@ public class MySQLPlayerDataManager extends PlayerDataManager { attributeinfo.addProperty(attribute, info.getAttributeLevel(attribute)); classinfo.add("attribute", attributeinfo); + JsonObject nodeLevelsInfo = new JsonObject(); + for (SkillTreeNode node : info.getNodeKeys()) + attributeinfo.addProperty(node.getFullId(), info.getNodeLevel(node)); + classinfo.add("node-levels", nodeLevelsInfo); + + JsonObject skillTreePointsInfo = new JsonObject(); + for (String skillTreeId : info.getSkillTreePointsKeys()) + attributeinfo.addProperty(skillTreeId, info.getSkillTreePoints(skillTreeId)); + classinfo.add("skill-tree-points", skillTreePointsInfo); + json.add(c, classinfo); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java index 86bb8c6c..145a02e4 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java @@ -175,11 +175,15 @@ public class YAMLPlayerDataManager extends PlayerDataManager { config.set("class-info." + key + ".skill-points", info.getSkillPoints()); config.set("class-info." + key + ".attribute-points", info.getAttributePoints()); config.set("class-info." + key + ".attribute-realloc-points", info.getAttributeReallocationPoints()); + config.set("class-info." + key + ".skill-tree-reallocation-points", info.getSkillTreeReallocationPoints()); + config.set("class-info." + key + ".skill-reallocation-points", info.getSkillReallocationPoints()); info.getSkillKeys().forEach(skill -> config.set("class-info." + key + ".skill." + skill, info.getSkillLevel(skill))); - info.getAttributeKeys() - .forEach(attribute -> config.set("class-info." + key + ".attribute." + attribute, info.getAttributeLevel(attribute))); + info.getAttributeKeys().forEach(attribute -> config.set("class-info." + key + ".attribute." + attribute, info.getAttributeLevel(attribute))); + info.getNodeKeys().forEach(node -> config.set("class-info." + key + ".node-levels." + node.getFullId(), info.getNodeLevel(node))); + info.getSkillTreePointsKeys().forEach(skillTreeId -> config.set("class-info." + key + ".skill-tree-points." + skillTreeId, info.getAttributeLevel(skillTreeId))); } + file.save(); }