From 60859fa503048bc088e5eeef20505d33ba07a537 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Mon, 17 Oct 2022 06:25:58 +0200 Subject: [PATCH] Add skill trees in class config --- .../mmocore/api/player/profess/PlayerClass.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java index f8089309..f24cb4a6 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java @@ -33,6 +33,7 @@ import net.Indyuce.mmocore.skill.RegisteredSkill; import net.Indyuce.mmocore.skill.cast.KeyCombo; import net.Indyuce.mmocore.skill.cast.PlayerKey; import net.Indyuce.mmocore.experience.ExperienceObject; +import net.Indyuce.mmocore.tree.skilltree.SkillTree; import net.md_5.bungee.api.ChatColor; import org.apache.commons.lang.Validate; import org.bukkit.Location; @@ -55,7 +56,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { private final ItemStack icon; private final Map options = new HashMap<>(); private final int maxLevel, displayOrder; - @NotNull private final ManaDisplayOptions manaDisplay; @@ -69,6 +69,8 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { private final CastingParticle castParticle; private final int maxBoundActiveSkills, maxBoundPassiveSkills; + + private final List skillTrees = new ArrayList<>(); private final List classScripts = new LinkedList(); private final Map stats = new HashMap<>(); private final Map skills = new LinkedHashMap<>(); @@ -77,7 +79,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { // If the class redefines its own key combos. private final Map combos = new HashMap<>(); - private final Set firstComboKeys= new HashSet<>(); + private final Set firstComboKeys = new HashSet<>(); private int longestCombo; @@ -105,7 +107,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { profileField.set(meta, gp); icon.setItemMeta(meta); } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException - | SecurityException exception) { + | SecurityException exception) { throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage()); } @@ -133,6 +135,8 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp table from class '" + id + "': " + exception.getMessage()); } this.expTable = expTable; + if (config.contains("skill-trees")) + config.getStringList("skill-trees").forEach(str-> skillTrees.add(MMOCore.plugin.skillTreeManager.get(str))); if (config.contains("scripts")) for (String key : config.getConfigurationSection("scripts").getKeys(false)) @@ -260,7 +264,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { setOption(ClassOption.DISPLAY, false); setOption(ClassOption.DEFAULT, false); maxBoundActiveSkills = 6; - maxBoundPassiveSkills=3; + maxBoundPassiveSkills = 3; for (PlayerResource resource : PlayerResource.values()) resourceHandlers.put(resource, new ResourceRegeneration(resource)); } @@ -319,6 +323,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { public int getMaxBoundActiveSkills() { return maxBoundActiveSkills; } + public int getMaxBoundPassiveSkills() { return maxBoundPassiveSkills; } @@ -429,6 +434,10 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { return skills.containsKey(id); } + public List getSkillTrees() { + return skillTrees; + } + public ClassSkill getSkill(RegisteredSkill skill) { return getSkill(skill.getHandler().getId()); }