Class ActionExecutionContext
java.lang.Object
de.oliver.fancynpcs.api.actions.executor.ActionExecutionContext
Context for executing a sequence of NPC actions initiated by different triggers.
-
Constructor Summary
ConstructorsConstructorDescriptionActionExecutionContext(ActionTrigger trigger, Npc npc) Constructs an ActionExecutionContext with the specified ActionTrigger and Npc, without a Player.ActionExecutionContext(ActionTrigger trigger, Npc npc, UUID player) Constructs an ActionExecutionContext with the specified ActionTrigger, Npc, and an optional Player. -
Method Summary
Modifier and TypeMethodDescriptionintgetNpc()org.bukkit.entity.PlayerbooleanhasNext()Checks if there are more actions to be executed.booleanChecks if the action sequence has been terminated.voidreset()Resets the current action index to its initial state.voidrun(int index) Executes the action at the specified index within the list of actions.voidrunNext()Executes the next action in the list of actions.booleanvoidTerminates the current action sequence by setting the action index to -1.
-
Constructor Details
-
ActionExecutionContext
Constructs an ActionExecutionContext with the specified ActionTrigger, Npc, and an optional Player.- Parameters:
trigger- the trigger that initiated the actionnpc- the NPC that the action is being executed onplayer- the player involved in the action, may be null if no player is involved
-
ActionExecutionContext
Constructs an ActionExecutionContext with the specified ActionTrigger and Npc, without a Player.- Parameters:
trigger- the trigger that initiated the actionnpc- the NPC that the action is being executed on
-
-
Method Details
-
run
public void run(int index) Executes the action at the specified index within the list of actions.- Parameters:
index- the index of the action to be executed. If the index is out of bounds, the method returns immediately.
-
runNext
public void runNext()Executes the next action in the list of actions.If the current action index is out of bounds, the method returns immediately. The action index is incremented after the action is executed.
-
hasNext
public boolean hasNext()Checks if there are more actions to be executed.- Returns:
- true if there are more actions to be executed, false otherwise
-
reset
public void reset()Resets the current action index to its initial state. This is useful for re-running the sequence of actions from the beginning. -
terminate
public void terminate()Terminates the current action sequence by setting the action index to -1. This effectively marks the context as finished and prevents any further actions from being executed. -
isTerminated
public boolean isTerminated()Checks if the action sequence has been terminated.- Returns:
- true if the action index is -1, indicating the sequence is terminated; false otherwise
-
shouldBlockUntilDone
public boolean shouldBlockUntilDone() -
getTrigger
-
getNpc
-
getActions
-
getPlayerUUID
-
getPlayer
@Nullable public org.bukkit.entity.Player getPlayer() -
getActionIndex
public int getActionIndex()
-