-
Notifications
You must be signed in to change notification settings - Fork 1
Step 3. Add custom action
toxicity188 edited this page Sep 11, 2023
·
1 revision
Here is my code example.
public class ActSetClass extends AbstractAction { //Action class must be extended class of kor.toxicity.questadder.api.mechanic.AbstractAction
//Data field must be annotated by kor.toxicity.questadder.api.util.DataField
@DataField(aliases = "n", throwIfNull = true) //aliases = an field name aliases, throwIfNull = making an error when this field is null
public String name; //Data field must be public
public ActSetClass(@NotNull QuestAdder adder) {
super(adder);
}
@Override
public void invoke(Player player //A player that run action, QuestAdderEvent questAdderEvent //A event that run action) {
var data = Fantasia.Companion.getPlayerData(player);
if (data != null) {
data.setClazz(name);
Fantasia.Companion.loadOption(player);
}
}
}QuestAdderAPI.getInstance().apiManager.addAction("setclass", ActSetClass::class.java)it actually works like this:
- setclass{n=knight}