From 6d21b40ce901c79963555012e1fa263a8cb59ad6 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Thu, 10 Nov 2022 18:01:40 +0100 Subject: [PATCH] More cleanup --- .../mmocore/api/player/PlayerData.java | 41 ++++++++----------- .../mmocore/experience/PlayerProfessions.java | 2 +- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 0d88ea6c..84f0cce5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -6,8 +6,6 @@ import io.lumine.mythic.lib.api.stat.StatInstance; import io.lumine.mythic.lib.api.stat.modifier.StatModifier; import io.lumine.mythic.lib.player.cooldown.CooldownMap; import io.lumine.mythic.lib.player.skill.PassiveSkill; -import net.Indyuce.mmocore.party.provided.MMOCorePartyModule; -import net.Indyuce.mmocore.party.provided.Party; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.ConfigMessage; import net.Indyuce.mmocore.api.SoundEvent; @@ -34,8 +32,9 @@ import net.Indyuce.mmocore.experience.droptable.ExperienceTable; import net.Indyuce.mmocore.guild.provided.Guild; import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect; import net.Indyuce.mmocore.party.AbstractParty; +import net.Indyuce.mmocore.party.provided.MMOCorePartyModule; +import net.Indyuce.mmocore.party.provided.Party; import net.Indyuce.mmocore.player.Unlockable; -import net.Indyuce.mmocore.player.stats.StatInfo; import net.Indyuce.mmocore.skill.ClassSkill; import net.Indyuce.mmocore.skill.RegisteredSkill; import net.Indyuce.mmocore.skill.cast.SkillCastingHandler; @@ -119,8 +118,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc private final Map tableItemClaims = new HashMap<>(); // NON-FINAL player data stuff made public to facilitate field change - public boolean noCooldown; - private final boolean statLoaded; + public boolean noCooldown, statsLoaded; public CombatRunnable combat; /** @@ -137,12 +135,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc playerStats = new PlayerStats(this); // Used to see if the triggers need to be applied - boolean statLoaded = false; for (StatInstance instance : mmoData.getStatMap().getInstances()) for (StatModifier modifier : instance.getModifiers()) - if (modifier.getKey().startsWith("trigger")) - statLoaded = true; - this.statLoaded = statLoaded; + if (modifier.getKey().startsWith("trigger")) { + statsLoaded = true; + break; + } } /** @@ -172,27 +170,25 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc j++; } - for (SkillTree skillTree : profess.getSkillTrees()) { - for (SkillTreeNode node : skillTree.getNodes()) { + for (SkillTree skillTree : getProfess().getSkillTrees()) + for (SkillTreeNode node : skillTree.getNodes()) if (!nodeLevels.containsKey(node)) nodeLevels.put(node, 0); - } - } setupSkillTree(); } public void setupSkillTree() { - //Node states setup - for (SkillTree skillTree : profess.getSkillTrees()) + // Node states setup + for (SkillTree skillTree : getProfess().getSkillTrees()) skillTree.setupNodeState(this); // Stat triggers setup - if (!statLoaded) { + if (!statsLoaded) { for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll()) for (SkillTreeNode node : skillTree.getNodes()) node.getExperienceTable().claimStatTriggers(this, node); - statLoaded = true; + statsLoaded = true; } } @@ -206,7 +202,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc public void clearPointsSpent() { pointSpent.clear(); - } public void setSkillTreePoints(String treeId, int points) { @@ -228,27 +223,23 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc return new HashMap(skillTreePoints); } - - public void clearSkillTreePoints() { skillTreePoints.clear(); } - public boolean containsSkillPointTreeId(String treeId) { return skillTreePoints.containsKey(treeId); } public Set> getNodeLevelsEntrySet() { HashMap nodeLevelsString = new HashMap<>(); - for (SkillTreeNode node : nodeLevels.keySet()) { + for (SkillTreeNode node : nodeLevels.keySet()) nodeLevelsString.put(node.getFullId(), nodeLevels.get(node)); - } return nodeLevelsString.entrySet(); } - public boolean isStatLoaded() { - return statLoaded; + public boolean areStatsLoaded() { + return statsLoaded; } public Map getNodeLevels() { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java index 4b16578b..868da7e5 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java @@ -100,7 +100,7 @@ public class PlayerProfessions { for (Entry entry : obj.getAsJsonObject("timesClaimed").entrySet()) playerData.getItemClaims().put("profession." + entry.getKey(), entry.getValue().getAsInt()); - if (!playerData.isStatLoaded()) + if (!playerData.areStatsLoaded()) for (Profession profession : MMOCore.plugin.professionManager.getAll()) { if (profession.hasExperienceTable()) profession.getExperienceTable().claimStatTriggers(playerData, profession);