Class ActionExecutionContext

java.lang.Object
de.oliver.fancynpcs.api.actions.executor.ActionExecutionContext

public class ActionExecutionContext extends Object
Context for executing a sequence of NPC actions initiated by different triggers.
  • Constructor Details

    • ActionExecutionContext

      public ActionExecutionContext(ActionTrigger trigger, Npc npc, @Nullable UUID player)
      Constructs an ActionExecutionContext with the specified ActionTrigger, Npc, and an optional Player.
      Parameters:
      trigger - the trigger that initiated the action
      npc - the NPC that the action is being executed on
      player - the player involved in the action, may be null if no player is involved
    • ActionExecutionContext

      public ActionExecutionContext(ActionTrigger trigger, Npc npc)
      Constructs an ActionExecutionContext with the specified ActionTrigger and Npc, without a Player.
      Parameters:
      trigger - the trigger that initiated the action
      npc - 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

      public ActionTrigger getTrigger()
    • getNpc

      public Npc getNpc()
    • getActions

      public List<NpcAction.NpcActionData> getActions()
    • getPlayerUUID

      public UUID getPlayerUUID()
    • getPlayer

      @Nullable public org.bukkit.entity.Player getPlayer()
    • getActionIndex

      public int getActionIndex()