Class Executor
java.lang.Object
ua.mcchickenstudio.opencreative.coding.blocks.executors.Executor
- All Implemented Interfaces:
CodingBlock, ExtensionContent
- Direct Known Subclasses:
EntityExecutor, NameableExecutor, PlayerExecutor, WorldExecutor
Executor
This class represents Executor that has actions to run. Executor will be executed on events in planet.- Since:
- 5.0
- Version:
- 6.0
- Author:
- McChicken Studio
-
Constructor Summary
ConstructorsConstructorDescriptionExecutor(@NotNull String id, @NotNull ExecutorCategory category) Constructor of empty Executor without block data. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidDecreases calls amount by 1.final booleanprotected voidexecuteActions(@NotNull WorldEvent event) Executes all actions with specified event.final @NotNull ExecutorCategoryReturns coding block category of this executor.final WorldEventgetEvent()Returns last world event of executor.final ActionsHandlerfinal @NotNull StringgetID()Returns id of executor, that will be used to find it in registry.final intReturns how many times executor was called to execute actions.final @NotNull StringReturns localized name of executor.final @NotNull PlanetReturns planet, that was associated with executor.final intgetX()Returns X coordinate of coding block's location.final intgetY()Returns Y coordinate of coding block's location.final intgetZ()Returns Z coordinate of coding block's location.final inthashCode()final voidIncreases calls amount by 1.voidInitializes an executor and sets planet and coding block location.final booleanisDebug()Checks whether is executor block marked for debugging.final booleanChecks whether executor is disabled and cannot be called.voidrun(@NotNull WorldEvent event) Checks executor, executes actions and sends information about executor.final voidsetActions(@NotNull List<Action> actions) Sets actions list for executor.final voidsetDebug(boolean debug) Enables or disables sending debug logs about executor and actions inside.toString()Methods inherited from interface ExtensionContent
getDescription, getExtensionId, getName
-
Constructor Details
-
Executor
Constructor of empty Executor without block data.Executing actions will be not able without initialization.
To initialize, use
init(Planet, int, int, int)- Parameters:
id- short id of executor that will be used in signs and translations.It must be lower-snake-cased, for example: "player_join", "cycle". If some of registered executors has same ID as new, it will be not added.
category- category of executor.
-
-
Method Details
-
init
Initializes an executor and sets planet and coding block location. Use this method after creating executor.- Parameters:
planet- Planet where executor will work.x- X from Executor's block location in developers planet.y- Y from Executor's block location in developers planet.z- Z from Executor's block location in developers planet.- Throws:
IllegalStateException- if executor is already initialized.
-
run
Checks executor, executes actions and sends information about executor.- Parameters:
event- Event that occurred in planet.- Throws:
IllegalStateException- if executor is not initialized.
-
executeActions
Executes all actions with specified event.- Parameters:
event- Event that has happened in planet.
-
getBlockCategory
Returns coding block category of this executor.- Returns:
- category of executor.
-
getPlanet
Returns planet, that was associated with executor.- Returns:
- planet.
-
isDebug
public final boolean isDebug()Checks whether is executor block marked for debugging.- Returns:
- true - for debug, false - not.
-
setDebug
public final void setDebug(boolean debug) Enables or disables sending debug logs about executor and actions inside.- Parameters:
debug- true - enabled, false - disabled.
-
getEvent
Returns last world event of executor.When a new event happens, it will be replaced with a new one.
- Returns:
- last world event.
-
getHandler
-
getActions
-
setActions
-
increaseCall
public final void increaseCall()Increases calls amount by 1. -
decreaseCall
public final void decreaseCall()Decreases calls amount by 1. -
getLastCalls
public final int getLastCalls()Returns how many times executor was called to execute actions.- Returns:
- amount of last executions.
-
isDisabled
public final boolean isDisabled()Checks whether executor is disabled and cannot be called.- Returns:
- true - disabled, false - not.
-
getID
Returns id of executor, that will be used to find it in registry.- Returns:
- id of executor.
-
getLocaleName
Returns localized name of executor.- Returns:
- localized name.
-
getX
public final int getX()Description copied from interface:CodingBlockReturns X coordinate of coding block's location.- Specified by:
getXin interfaceCodingBlock- Returns:
- X coordinate.
-
getY
public final int getY()Description copied from interface:CodingBlockReturns Y coordinate of coding block's location.- Specified by:
getYin interfaceCodingBlock- Returns:
- Y coordinate.
-
getZ
public final int getZ()Description copied from interface:CodingBlockReturns Z coordinate of coding block's location.- Specified by:
getZin interfaceCodingBlock- Returns:
- Z coordinate.
-
hashCode
-
toString
-
equals
-