Fixed an issue with default passive skills

This commit is contained in:
Jules 2022-02-06 17:39:19 +01:00
parent e20eb8b547
commit 87ffe8e621
3 changed files with 11 additions and 5 deletions

View File

@ -102,11 +102,11 @@ public class PlayerStats {
* as statistics (when the player level changes, when his class * as statistics (when the player level changes, when his class
* changes, when he logs on..) * changes, when he logs on..)
* *
* This updates the player's passive skills * This updates the player's PASSIVE skills
*/ */
data.getMMOPlayerData().getPassiveSkillMap().removeModifiers("MMOCorePassiveSkill"); data.getMMOPlayerData().getPassiveSkillMap().removeModifiers("MMOCorePassiveSkill");
for (ClassSkill skill : data.getProfess().getSkills()) for (ClassSkill skill : data.getProfess().getSkills())
if (skill.getSkill().hasTrigger()) if (skill.getSkill().isPassive())
data.getMMOPlayerData().getPassiveSkillMap().addModifier(skill.toPassive(data)); data.getMMOPlayerData().getPassiveSkillMap().addModifier(skill.toPassive(data));
} }
} }

View File

@ -114,8 +114,8 @@ public class ClassSkill implements CooldownObject {
} }
public PassiveSkill toPassive(PlayerData caster) { public PassiveSkill toPassive(PlayerData caster) {
Validate.isTrue(skill.hasTrigger(), "Skill is active"); Validate.isTrue(skill.isPassive(), "Skill is active");
return new PassiveSkill("MMOCorePassiveSkill", skill.getTrigger(), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER); return new PassiveSkill("MMOCorePassiveSkill", skill.getTriggerOrNull(), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER);
} }
@Override @Override

View File

@ -32,7 +32,8 @@ public class RegisteredSkill {
lore = Objects.requireNonNull(config.getStringList("lore"), "Could not find skill lore"); lore = Objects.requireNonNull(config.getStringList("lore"), "Could not find skill lore");
// Trigger type // Trigger type
Validate.isTrue(getHandler().isTriggerable() || !config.contains("passive-type"), "Cannot change the trigger type of a default passive skill"); Validate.isTrue(!getHandler().isTriggerable() || config.contains("passive-type"), "Please provide a passive type");
Validate.isTrue(getHandler().isTriggerable() || !config.contains("passive-type"), "Cannot change passive type of a default passive skill");
triggerType = config.contains("passive-type") ? TriggerType.valueOf(config.getString("passive-type").toUpperCase().replace(" ", "_").replace("-", "_")) : null; triggerType = config.contains("passive-type") ? TriggerType.valueOf(config.getString("passive-type").toUpperCase().replace(" ", "_").replace("-", "_")) : null;
for (String mod : handler.getModifiers()) for (String mod : handler.getModifiers())
@ -101,6 +102,11 @@ public class RegisteredSkill {
return Objects.requireNonNull(triggerType, "Skill has no trigger"); return Objects.requireNonNull(triggerType, "Skill has no trigger");
} }
@Nullable
public TriggerType getTriggerOrNull() {
return triggerType;
}
public void addModifier(String modifier, LinearValue linear) { public void addModifier(String modifier, LinearValue linear) {
defaultModifiers.put(modifier, linear); defaultModifiers.put(modifier, linear);
} }