mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
Added a Stamina Trigger
This commit is contained in:
parent
15abd09acd
commit
bc535130c5
@ -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.ManaTrigger;
|
||||||
import net.Indyuce.mmocore.api.quest.trigger.MessageTrigger;
|
import net.Indyuce.mmocore.api.quest.trigger.MessageTrigger;
|
||||||
import net.Indyuce.mmocore.api.quest.trigger.SoundTrigger;
|
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.StelliumTrigger;
|
||||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||||
@ -54,6 +55,9 @@ public class DefaultMMOLoader extends MMOLoader {
|
|||||||
if (config.getKey().equals("mana"))
|
if (config.getKey().equals("mana"))
|
||||||
return new ManaTrigger(config);
|
return new ManaTrigger(config);
|
||||||
|
|
||||||
|
if (config.getKey().equals("stamina"))
|
||||||
|
return new StaminaTrigger(config);
|
||||||
|
|
||||||
if (config.getKey().equals("stellium"))
|
if (config.getKey().equals("stellium"))
|
||||||
return new StelliumTrigger(config);
|
return new StelliumTrigger(config);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user