-
Notifications
You must be signed in to change notification settings - Fork 1
Step 4. Add custom event
toxicity188 edited this page Sep 11, 2023
·
1 revision
Here is my code example.
public class EventSkillAction extends AbstractEvent<SkillActionEvent> {
@DataField(aliases = "d")
public Direction direction; //You can handle enum constant too.
@DataField(aliases = "w")
public WeaponKey weaponKey;
public EventSkillAction(QuestAdder adder, AbstractAction action) { //You must set constructor to this format: QuestAdder, T
super(adder, action, SkillActionEvent.class);
}
@Override
public void invoke(SkillActionEvent skillActionEvent) {
if (direction != null && direction != skillActionEvent.getDirection()) return;
if (weaponKey != null && weaponKey != skillActionEvent.getWeaponKey()) return;
apply(skillActionEvent.getPlayer()); //Call this method to run action.
}
}
QuestAdderAPI.getInstance().apiManager.addEvent("skillaction", EventSkillAction::class.java)
It actually works like this.
variable:
1:
event: skillaction{w=LEFT}
name: action_1
lore: "play left attack 20 times."
max: 20