Class Action

java.lang.Object
dev.foxikle.customnpcs.actions.Action

public class Action extends Object
The object to represent what should be done after an NPC interaction
  • Constructor Details

    • Action

      public Action(ActionType actionType, List<String> args, int delay, Conditional.SelectionMode matchAll, List<Conditional> conditionals)

      Creates a new Action

      Parameters:
      actionType - The type of action to be performed
      args - The arguments for the Action
      delay - The amount of ticks to delay an action
      matchAll - If all the conditions must be met, or one
      conditionals - The conditions to apply to this action
  • Method Details

    • getArgsCopy

      public List<String> getArgsCopy()

      Gets a copy of the arguments of an action

      Returns:
      A copy of the list of arguments for the actions
    • addConditional

      public boolean addConditional(Conditional conditional)
      Adds a condition to the action
      Parameters:
      conditional - the conditional to add
      Returns:
      if the conditional was successfully added
    • removeConditional

      public boolean removeConditional(Conditional conditional)
      Removes a condition from the action
      Parameters:
      conditional - conditional to remove
      Returns:
      if the condition was successfully removed
    • getCommand

      public String getCommand(@NotNull @NotNull org.bukkit.entity.Player player)
      Gets the command that is run to initiate the action.
      Parameters:
      player - the action is targeted at
      Returns:
      String representing the command. The arguments are: player's uuid, sub command, delay (in ticks), command specific arguments
    • of

      Gets the action from a serialized string

      Parameters:
      string - The string to deserialize.
      Returns:
      the action that was serialized.
      Throws:
      NumberFormatException - If the string was formatted improperly
      ArrayIndexOutOfBoundsException - if the action was formatted impropperly
    • toJson

      public String toJson()

      Gets the json equivalent of this action

      Returns:
      the serialized version of the action (in json)
    • clone

      public Action clone()
      Overrides:
      clone in class Object