Class Action

java.lang.Object
ua.mcchickenstudio.opencreative.coding.blocks.actions.Action
All Implemented Interfaces:
CodingBlock
Direct Known Subclasses:
Condition, ControlAction, EntityAction, LaunchFunctionAction, LaunchMethodAction, MultiAction, PlayerAction, SelectionAction, VariableAction, WorldAction

public abstract class Action extends Object implements CodingBlock

Action

This class represents Action that will be executed in executor.
Since:
5.0
Version:
6.0
Author:
McChicken Studio
  • Field Details

    • arguments

      protected final Arguments arguments
    • entity

      protected org.bukkit.entity.Entity entity
    • event

      protected WorldEvent event
    • handler

      protected ActionsHandler handler
  • Constructor Details

    • Action

      public Action(Executor executor, Target target, int x, Arguments args)
      Creates an Action with linked executor and specified arguments.
      Parameters:
      executor - Executor where this action will be added.
      target - Target, that will execute this action.
      x - X coordinate from Action's block location in developers planet.
      args - List of arguments for action.
  • Method Details

    • prepareAndExecute

      public void prepareAndExecute(@NotNull @NotNull ActionsHandler handler)
      Prepares action for executing, sets handler and event, and executes action with target.
      Parameters:
      handler - ActionsHandler that stores event data and temporary variables.
    • execute

      protected abstract void execute(@Nullable @Nullable org.bukkit.entity.Entity entity)
      Executes action with specified entity.
      Parameters:
      entity - Entity to execute action.
    • getActionType

      @NotNull public abstract @NotNull ActionType getActionType()
      Returns type of action, that contains information about action: icon material, arguments list.
      Returns:
      Type of action.
    • getActionCategory

      @NotNull public abstract @NotNull ActionCategory getActionCategory()
      Returns category of action, that contains information about action: glass pane materials, block materials.
      Returns:
      Category of action.
    • getArguments

      @NotNull protected final @NotNull Arguments getArguments()
      Returns arguments of action.
      Returns:
      Arguments of action.
    • getExecutor

      public final Executor getExecutor()
      Returns executor, that stores this action.
      Returns:
      Executor with this action.
    • getEntitiesByNameOrUUID

      protected Set<org.bukkit.entity.Entity> getEntitiesByNameOrUUID(String text)
      Returns a set of entities whose name or UUID is equal to specified text.
      Parameters:
      text - Text to compare world's entities names and UUIDs.
      Returns:
      Set of entities with same names or UUIDs, as text.
    • getEntityByNameOrUUID

      @Nullable protected @Nullable org.bukkit.entity.Entity getEntityByNameOrUUID(String text)
      Returns an entity whose name or UUID is equal to specified text.
      Parameters:
      text - Text to compare world's entities names and UUIDs.
      Returns:
      Entity, or null.
    • getPlayersByNameOrUUID

      protected Set<org.bukkit.entity.Player> getPlayersByNameOrUUID(String text)
    • getWorld

      protected org.bukkit.World getWorld()
      Returns planet's world, where action will be executed.
      Returns:
      Planet's world.
    • getPlanet

      protected Planet getPlanet()
    • getEntity

      public org.bukkit.entity.Entity getEntity()
      Returns involved entity in action from ActionsHandler.
      Returns:
      Involved entity.
    • setEntity

      public void setEntity(org.bukkit.entity.Entity entity)
      Sets entity involved in executor's event.
      Parameters:
      entity - New entity.
    • getEvent

      public WorldEvent getEvent()
      Returns last stored event in action.
      Returns:
      CreativeEvent, that called executor with this action.
    • setEvent

      public void setEvent(WorldEvent event)
      Sets new event.
      Parameters:
      event - new event of action.
    • getHandler

      public ActionsHandler getHandler()
      Returns current ActionsHandler in action.
      Returns:
      Handler of this action.
    • setHandler

      public void setHandler(ActionsHandler handler)
      Sets new ActionsHandler.
      Parameters:
      handler - New handler of action.
    • getTarget

      public Target getTarget()
      Returns enum of target.
      Returns:
      Enum of target.
    • getTargets

      protected List<org.bukkit.entity.Entity> getTargets()
      Returns list of entities that will execute this action.
      Returns:
      List of entities to execute action.
    • setVarValue

      protected void setVarValue(@Nullable @Nullable VariableLink link, Object value)
      Sets value in local, global or saved variable in world.
      Parameters:
      link - Link of variable.
      value - New value.
    • getArgumentsList

      public List<Argument> getArgumentsList()
      Returns a list of all arguments in this action.
      Returns:
      List of action's arguments.
    • getX

      public int getX()
      Description copied from interface: CodingBlock
      Returns X coordinate of coding block's location.
      Specified by:
      getX in interface CodingBlock
      Returns:
      X coordinate.
    • getY

      public int getY()
      Description copied from interface: CodingBlock
      Returns Y coordinate of coding block's location.
      Specified by:
      getY in interface CodingBlock
      Returns:
      Y coordinate.
    • getZ

      public int getZ()
      Description copied from interface: CodingBlock
      Returns Z coordinate of coding block's location.
      Specified by:
      getZ in interface CodingBlock
      Returns:
      Z coordinate.