Class ActionsHandler
java.lang.Object
ua.mcchickenstudio.opencreative.coding.blocks.actions.ActionsHandler
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 Summary
ConstructorsConstructorDescriptionActionsHandler(@NotNull Action action) Constructor of actions handler with multi action (with brackets).ActionsHandler(@NotNull Executor executor) Constructor of actions handler with executor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddActions(@NotNull List<Action> actions) Inserts actions and executes them.final voidexecuteActions(@NotNull List<Action> actions) Adds actions to queue and executes them.voidExecutes next action from queue.@Nullable ActionReturns multi action with brackets, that launched actions handler, if exists.getEvent()Returns world event, that launched executor.Returns executor, that launched actions handler.@Nullable ActionsHandlergetFirstActionsHandler(@NotNull ActionCategory category) Returns first parent action handler with specified category of action.@Nullable org.bukkit.entity.EntityReturns last spawned entity by code.@NotNull ActionsHandlerReturns the main actions handler (executor thread).@Nullable ActionsHandlerReturns parent actions handler, if exists.Set<org.bukkit.entity.Entity> Returns selected targets, that can be modified with selection action.final UUIDReturns an unique ID of actions handler.longReturns how many ticks should pass before executing next action from queue.booleanChecks whether action handler flagged to stop.voidprepareAction(Action action) Prepares action and executes it.voidClears all actions from queue.voidsetLastSpawnedEntity(org.bukkit.entity.Entity lastSpawnedEntity) Sets last spawned entity.voidsetSelectedTargets(@NotNull Set<org.bukkit.entity.Entity> targets) Sets selected targets for actions with "selection" target.voidsetStopped(boolean stopped) Sets stopped flag to actions handler.voidsetWaitDelay(long waitDelay) Sets how many ticks should pass before executing next action.voidStops code in all parent handlers.toString()
-
Constructor Details
-
ActionsHandler
Constructor of actions handler with executor.The executor is main handler of actions.
- Parameters:
executor- executor that contains actions to execute.
-
ActionsHandler
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
-
addActions
-
executeNextAction
public void executeNextAction()Executes next action from queue. -
prepareAction
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
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
Returns parent actions handler, if exists.- Returns:
- parent actions handler, or null.
-
getEvent
-
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
-
getAction
Returns multi action with brackets, that launched actions handler, if exists.- Returns:
- action, or null.
-
getSelectedTargets
Returns selected targets, that can be modified with selection action.- Returns:
- selected targets.
-
setSelectedTargets
Sets selected targets for actions with "selection" target.- Parameters:
targets- new targets.
-
toString
-
getUniqueId
-