diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java index 4a77bdbf..a99fda41 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StatTrigger.java @@ -4,11 +4,12 @@ import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.stat.modifier.StatModifier; import io.lumine.mythic.lib.player.modifier.ModifierType; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.quest.trigger.api.Removable; import org.apache.commons.lang.Validate; import java.util.UUID; -public class StatTrigger extends Trigger { +public class StatTrigger extends Trigger implements Removable { public static String TRIGGER_PREFIX = "mmocore_trigger"; private final StatModifier statModifier; private final String stat; @@ -42,6 +43,7 @@ public class StatTrigger extends Trigger { * opposite amount. (Little corrective term for the relative to have the inverse. * Not a problem to store twice the stat modifiers are there only remain in the RAM. */ + @Override public void remove(PlayerData playerData) { playerData.getMMOPlayerData().getStatMap().getInstance(stat).remove(modifierKey); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/UnlockSkillTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/UnlockSkillTrigger.java new file mode 100644 index 00000000..4fc77c40 --- /dev/null +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/UnlockSkillTrigger.java @@ -0,0 +1,29 @@ +package net.Indyuce.mmocore.api.quest.trigger; + +import io.lumine.mythic.lib.api.MMOLineConfig; +import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.quest.trigger.api.Removable; +import net.Indyuce.mmocore.skill.RegisteredSkill; + +import java.util.Objects; + +public class UnlockSkillTrigger extends Trigger implements Removable { + private final RegisteredSkill skill; + + public UnlockSkillTrigger(MMOLineConfig config) { + super(config); + config.validateKeys("skill"); + skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(config.getString("skill"))); + } + + @Override + public void apply(PlayerData player) { + player.unlock(skill); + } + + @Override + public void remove(PlayerData playerData) { + playerData.lock(skill); + } +} diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/api/Removable.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/api/Removable.java new file mode 100644 index 00000000..533683ca --- /dev/null +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/api/Removable.java @@ -0,0 +1,7 @@ +package net.Indyuce.mmocore.api.quest.trigger.api; + +import net.Indyuce.mmocore.api.player.PlayerData; + +public interface Removable { + public void remove(PlayerData playerData); +}