Fixed issue #857 about progress not being properly saved for skill trees with skill modifier. (Skill modifier is now the name we will give to skill buffs. mana, delay... are now called skill parameters).

This commit is contained in:
Ka0rX 2023-06-04 21:23:06 +01:00
parent 90e0c349a4
commit 72f14547d9
9 changed files with 23 additions and 23 deletions

View File

@ -35,7 +35,7 @@ public class DefaultMMOLoader extends MMOLoader {
if (config.getKey().equals("levelup_skill"))
return new LevelUpSkillTrigger(config);
if (config.getKey().equals("skill_buff"))
if (config.getKey().equals("skill_buff")||config.getKey().equals("skill_modifier"))
return new SkillModifierTrigger(config);
if (config.getKey().equals("message"))

View File

@ -190,7 +190,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
// Stat triggers setup
for (SkillTree skillTree : MMOCore.plugin.skillTreeManager.getAll())
for (SkillTreeNode node : skillTree.getNodes())
node.getExperienceTable().claimStatTriggers(this, node);
node.getExperienceTable().claimRemovableTrigger(this, node);
}
public int getPointSpent(SkillTree skillTree) {

View File

@ -345,8 +345,8 @@ public class SavedClassInformation implements ClassDataContainer {
// We claim back the stats triggers for all the skill tree nodes of the new class.
for (SkillTree skillTree : profess.getSkillTrees())
for (SkillTreeNode node : skillTree.getNodes())
node.getExperienceTable().claimStatTriggers(player, node);
profess.getExperienceTable().claimStatTriggers(player, profess);
node.getExperienceTable().claimRemovableTrigger(player, node);
profess.getExperienceTable().claimRemovableTrigger(player, profess);
// Unload current class information
player.unloadClassInfo(profess);

View File

@ -52,7 +52,7 @@ public class SkillModifierTrigger extends Trigger implements Removable {
}
/**
* Used by skill slots to apply a skillBuff
* Used by skill slots to apply a skill modifier.
* to a dynamically chosen skill handler.
*/
public void apply(PlayerData playerData, SkillHandler<?> skill) {

View File

@ -103,10 +103,10 @@ public class PlayerProfessions {
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
if (profession.hasExperienceTable())
profession.getExperienceTable().claimStatTriggers(playerData, profession);
profession.getExperienceTable().claimRemovableTrigger(playerData, profession);
}
if (playerData.getProfess().hasExperienceTable())
playerData.getProfess().getExperienceTable().claimStatTriggers(playerData, playerData.getProfess());
playerData.getProfess().getExperienceTable().claimRemovableTrigger(playerData, playerData.getProfess());
}

View File

@ -96,7 +96,7 @@ public class ExperienceItem {
* @param professionLevel The profession level the player just reached
* @param timesCollected Amount of times the exp item has already been claimed by the player
* @return If the item should be claimed right now taking into
* account the randomness factor from the 'chance' parameter
* account the randomness factor from the 'chance' parameter
*/
public boolean roll(int professionLevel, int timesCollected) {
@ -136,8 +136,8 @@ public class ExperienceItem {
*
* @param playerData
*/
public void applyStatTriggers(PlayerData playerData) {
public void applyRemovableTrigger(PlayerData playerData) {
for (Trigger trigger : triggers)
if (trigger instanceof StatTrigger statTrigger) statTrigger.apply(playerData);
if (trigger instanceof Removable) trigger.apply(playerData);
}
}

View File

@ -80,16 +80,16 @@ public class ExperienceTable {
/**
* Called when a player joins and all the statTriggers are all triggered back
* Called when a player joins and all the removable triggers get claimed back.
*
* @param data PlayerData
* @param object Either profession, skillTreeNode or class leveling up
*/
public void claimStatTriggers(PlayerData data, ExperienceObject object) {
public void claimRemovableTrigger(PlayerData data, ExperienceObject object) {
for (ExperienceItem item : items) {
int timesClaimed = data.getClaims(object, this, item);
for (int i = 0; i < timesClaimed; i++)
item.applyStatTriggers(data);
item.applyRemovableTrigger(data);
}
}

View File

@ -29,9 +29,9 @@ public class BoundSkillInfo implements Closable {
this.playerData = playerData;
// Apply skill buffs associated to the slot
for (SkillModifierTrigger skillBuffTrigger : skillSlot.getSkillBuffTriggers())
if (skillBuffTrigger.getTargetSkills().contains(classSkill.getSkill().getHandler()))
skillBuffTrigger.apply(playerData, classSkill.getSkill().getHandler());
for (SkillModifierTrigger skillModifierTrigger : skillSlot.getSkillModifierTriggers())
if (skillModifierTrigger.getTargetSkills().contains(classSkill.getSkill().getHandler()))
skillModifierTrigger.apply(playerData, classSkill.getSkill().getHandler());
if (classSkill.getSkill().getTrigger().isPassive()) {
registered = classSkill.toPassive(playerData);
@ -67,6 +67,6 @@ public class BoundSkillInfo implements Closable {
if (isPassive()) registered.unregister(playerData.getMMOPlayerData());
// Remove skill buffs associated to the slot
skillSlot.getSkillBuffTriggers().forEach(skillBuffTrigger -> skillBuffTrigger.remove(playerData, classSkill.getSkill().getHandler()));
skillSlot.getSkillModifierTriggers().forEach(skillBuffTrigger -> skillBuffTrigger.remove(playerData, classSkill.getSkill().getHandler()));
}
}

View File

@ -22,10 +22,10 @@ public class SkillSlot implements Unlockable {
private final boolean isUnlockedByDefault;
private final boolean canManuallyBind;
private final List<SkillModifierTrigger> skillBuffTriggers = new ArrayList<>();
private final List<SkillModifierTrigger> skillModifierTriggers = new ArrayList<>();
private final Material item;
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, boolean isUnlockedByDefault, boolean canManuallyBind, List<SkillModifierTrigger> skillBuffTriggers) {
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, boolean isUnlockedByDefault, boolean canManuallyBind, List<SkillModifierTrigger> skillModifierTriggers) {
this.slot = slot;
this.modelData = modelData;
this.formula = formula;
@ -34,7 +34,7 @@ public class SkillSlot implements Unlockable {
this.item = null;
this.canManuallyBind = canManuallyBind;
this.isUnlockedByDefault = isUnlockedByDefault;
this.skillBuffTriggers.addAll(skillBuffTriggers);
this.skillModifierTriggers.addAll(skillModifierTriggers);
}
public SkillSlot(ConfigurationSection section) {
@ -49,7 +49,7 @@ public class SkillSlot implements Unlockable {
if (section.contains("skill-buffs"))
for (String skillBuff : section.getStringList("skill-buffs"))
if (skillBuff.startsWith("skill_buff"))
skillBuffTriggers.add((SkillModifierTrigger) MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(skillBuff)));
skillModifierTriggers.add((SkillModifierTrigger) MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(skillBuff)));
}
public int getSlot() {
@ -81,8 +81,8 @@ public class SkillSlot implements Unlockable {
return isUnlockedByDefault;
}
public List<SkillModifierTrigger> getSkillBuffTriggers() {
return skillBuffTriggers;
public List<SkillModifierTrigger> getSkillModifierTriggers() {
return skillModifierTriggers;
}
public boolean canManuallyBind() {