From 87ffe8e621895bb719dbcfd41bec1b1578f11cf7 Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 6 Feb 2022 17:39:19 +0100 Subject: [PATCH] Fixed an issue with default passive skills --- .../net/Indyuce/mmocore/api/player/stats/PlayerStats.java | 4 ++-- src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java | 4 ++-- .../java/net/Indyuce/mmocore/skill/RegisteredSkill.java | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java index 3fc2eecd..26ab1176 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java @@ -102,11 +102,11 @@ public class PlayerStats { * as statistics (when the player level changes, when his class * changes, when he logs on..) * - * This updates the player's passive skills + * This updates the player's PASSIVE skills */ data.getMMOPlayerData().getPassiveSkillMap().removeModifiers("MMOCorePassiveSkill"); for (ClassSkill skill : data.getProfess().getSkills()) - if (skill.getSkill().hasTrigger()) + if (skill.getSkill().isPassive()) data.getMMOPlayerData().getPassiveSkillMap().addModifier(skill.toPassive(data)); } } diff --git a/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java b/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java index d4a70658..caf60439 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java +++ b/src/main/java/net/Indyuce/mmocore/skill/ClassSkill.java @@ -114,8 +114,8 @@ public class ClassSkill implements CooldownObject { } public PassiveSkill toPassive(PlayerData caster) { - Validate.isTrue(skill.hasTrigger(), "Skill is active"); - return new PassiveSkill("MMOCorePassiveSkill", skill.getTrigger(), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER); + Validate.isTrue(skill.isPassive(), "Skill is active"); + return new PassiveSkill("MMOCorePassiveSkill", skill.getTriggerOrNull(), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER); } @Override diff --git a/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java b/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java index fc17ba66..4d79d40d 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java +++ b/src/main/java/net/Indyuce/mmocore/skill/RegisteredSkill.java @@ -32,7 +32,8 @@ public class RegisteredSkill { lore = Objects.requireNonNull(config.getStringList("lore"), "Could not find skill lore"); // 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; for (String mod : handler.getModifiers()) @@ -101,6 +102,11 @@ public class RegisteredSkill { return Objects.requireNonNull(triggerType, "Skill has no trigger"); } + @Nullable + public TriggerType getTriggerOrNull() { + return triggerType; + } + public void addModifier(String modifier, LinearValue linear) { defaultModifiers.put(modifier, linear); }