Class ActionsHandler

java.lang.Object
ua.mcchickenstudio.opencreative.coding.blocks.actions.ActionsHandler

public class ActionsHandler extends Object

ActionHandler

This class represents actions handler that executes every action in list. Executors and code blocks with brackets use handlers to execute code inside brackets.
Since:
5.0
Version:
6.0
Author:
McChicken Studio
See Also:
  • Constructor Details

    • ActionsHandler

      public ActionsHandler(@NotNull @NotNull Executor executor)
      Constructor of actions handler with executor.

      The executor is main handler of actions.

      Parameters:
      executor - executor that contains actions to execute.
    • ActionsHandler

      public ActionsHandler(@NotNull @NotNull Action action)
      Constructor of actions handler with multi action (with brackets).

      Changes (to selection, or stopping code line) will be also applied to parent actions handler.

      Parameters:
      action - multi action that contains actions to execute.
  • Method Details

    • executeActions

      public final void executeActions(@NotNull @NotNull List<Action> actions)
      Adds actions to queue and executes them.
      Parameters:
      actions - actions to execute.
    • addActions

      public final void addActions(@NotNull @NotNull List<Action> actions)
      Inserts actions and executes them. Used in functions.

      Actions from previous queue will be moved to the end.

      Parameters:
      actions - actions to execute first.
    • executeNextAction

      public void executeNextAction()
      Executes next action from queue.
    • prepareAction

      public void prepareAction(Action action)
      Prepares action and executes it.
      Parameters:
      action - action to prepare and execute.
    • removeAllActions

      public void removeAllActions()
      Clears all actions from queue.

      Nothing will be executed.

    • getWaitDelay

      public long getWaitDelay()
      Returns how many ticks should pass before executing next action from queue.
      Returns:
      wait delay.
    • setWaitDelay

      public void setWaitDelay(long waitDelay)
      Sets how many ticks should pass before executing next action.
      Parameters:
      waitDelay - wait delay.
    • getMainActionHandler

      @NotNull public @NotNull ActionsHandler getMainActionHandler()
      Returns the main actions handler (executor thread).
      Returns:
      the main handler of actions.
    • getLastSpawnedEntity

      @Nullable public @Nullable org.bukkit.entity.Entity getLastSpawnedEntity()
      Returns last spawned entity by code.
      Returns:
      last spawned entity.
    • setLastSpawnedEntity

      public void setLastSpawnedEntity(org.bukkit.entity.Entity lastSpawnedEntity)
      Sets last spawned entity.
      Parameters:
      lastSpawnedEntity - last spawned entity.
    • isStopped

      public boolean isStopped()
      Checks whether action handler flagged to stop.
      Returns:
      true - stopped, false - not.
    • setStopped

      public void setStopped(boolean stopped)
      Sets stopped flag to actions handler.
      Parameters:
      stopped - true - will stop code, false - not.
    • getParentActionHandler

      @Nullable public @Nullable ActionsHandler getParentActionHandler()
      Returns parent actions handler, if exists.
      Returns:
      parent actions handler, or null.
    • getEvent

      public WorldEvent getEvent()
      Returns world event, that launched executor.
      Returns:
      world event.
    • stopAllParentHandlers

      public void stopAllParentHandlers()
      Stops code in all parent handlers.
    • getFirstActionsHandler

      @Nullable public @Nullable ActionsHandler getFirstActionsHandler(@NotNull @NotNull ActionCategory category)
      Returns first parent action handler with specified category of action.

      If it doesn't find an action handler, it will return null.

      Parameters:
      category - category of action.
      Returns:
      action handler with action category, or null - if not found.
    • getExecutor

      public Executor getExecutor()
      Returns executor, that launched actions handler.
      Returns:
      executor.
    • getAction

      @Nullable public @Nullable Action getAction()
      Returns multi action with brackets, that launched actions handler, if exists.
      Returns:
      action, or null.
    • getSelectedTargets

      public Set<org.bukkit.entity.Entity> getSelectedTargets()
      Returns selected targets, that can be modified with selection action.
      Returns:
      selected targets.
    • setSelectedTargets

      public void setSelectedTargets(@NotNull @NotNull Set<org.bukkit.entity.Entity> targets)
      Sets selected targets for actions with "selection" target.
      Parameters:
      targets - new targets.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUniqueId

      public final UUID getUniqueId()
      Returns an unique ID of actions handler.
      Returns:
      UUID of handler.