Fixed perm stat bugs when changing class.

This commit is contained in:
Ka0rX 2022-12-20 18:40:26 +01:00
parent 82943e28d9
commit 88a3cc4282
2 changed files with 20 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.RegisteredSkill;
@ -237,11 +238,12 @@ public class SavedClassInformation {
player.clearNodeLevels();
player.clearNodeStates();
player.clearPointsSpent();
// We reset the experience table for each skill tree node to remove the perm stat.
// We remove perm stats for nodes and class.
for (SkillTree skillTree : player.getProfess().getSkillTrees()) {
for (SkillTreeNode node : skillTree.getNodes())
node.getExperienceTable().reset(player, node);
node.getExperienceTable().removePermStats(player, node);
}
player.getProfess().getExperienceTable().removePermStats(player, player.getProfess());
while (player.hasPassiveSkillBound(0))
player.unbindPassiveSkill(0);
@ -289,7 +291,7 @@ public class SavedClassInformation {
for (SkillTree skillTree : profess.getSkillTrees())
for (SkillTreeNode node : skillTree.getNodes())
node.getExperienceTable().claimStatTriggers(player, node);
profess.getExperienceTable().claimStatTriggers(player,profess);
/*
* unload current class information and set the new profess once
* everything is changed

View File

@ -54,6 +54,18 @@ public class ExperienceTable {
}
}
/**
* Called when a player changes its class.
* Removes the perm stat but keeps the item claims in memory.
*/
public void removePermStats(PlayerData playerData, ExperienceObject object) {
for (ExperienceItem item : items) {
int timesClaimed = playerData.getClaims(object, this, item);
for (int i = 0; i < timesClaimed; i++)
item.removeStatTriggers(playerData);
}
}
/**
* Called when the progression is reset(e.g skill tree reallocation)
*/