diff --git a/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java b/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java index cfdb4957..4959e98c 100644 --- a/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java +++ b/src/main/java/net/Indyuce/mmocore/api/load/DefaultMMOLoader.java @@ -37,6 +37,7 @@ import net.Indyuce.mmocore.api.quest.trigger.ItemTrigger; import net.Indyuce.mmocore.api.quest.trigger.ManaTrigger; import net.Indyuce.mmocore.api.quest.trigger.MessageTrigger; import net.Indyuce.mmocore.api.quest.trigger.SoundTrigger; +import net.Indyuce.mmocore.api.quest.trigger.StaminaTrigger; import net.Indyuce.mmocore.api.quest.trigger.StelliumTrigger; import net.Indyuce.mmocore.api.quest.trigger.Trigger; import net.mmogroup.mmolib.api.MMOLineConfig; @@ -54,6 +55,9 @@ public class DefaultMMOLoader extends MMOLoader { if (config.getKey().equals("mana")) return new ManaTrigger(config); + if (config.getKey().equals("stamina")) + return new StaminaTrigger(config); + if (config.getKey().equals("stellium")) return new StelliumTrigger(config); diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StaminaTrigger.java b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StaminaTrigger.java new file mode 100644 index 00000000..848c67ca --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/StaminaTrigger.java @@ -0,0 +1,46 @@ +package net.Indyuce.mmocore.api.quest.trigger; + +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.util.math.formula.RandomAmount; +import net.mmogroup.mmolib.api.MMOLineConfig; + +public class StaminaTrigger extends Trigger { + private final RandomAmount amount; + private final Operation operation; + + public StaminaTrigger(MMOLineConfig config) { + super(config); + + config.validate("amount"); + amount = new RandomAmount(config.getString("amount")); + operation = config.contains("operation") ? Operation.valueOf(config.getString("operation").toUpperCase()) : Operation.GIVE; + } + + @Override + public void apply(PlayerData player) { + + /* + * give mana + */ + if (operation == Operation.GIVE) + player.giveStamina(amount.calculate()); + + /* + * set mana + */ + else if (operation == Operation.SET) + player.setStamina(amount.calculate()); + + /* + * take mana + */ + else + player.giveStamina(-amount.calculate()); + } + + public enum Operation { + GIVE, + SET, + TAKE; + } +}