Package dev.foxikle.customnpcs.actions
Class Action
java.lang.Object
dev.foxikle.customnpcs.actions.Action
The object to represent what should be done after an NPC interaction
-
Constructor Summary
ConstructorsConstructorDescriptionAction
(ActionType actionType, List<String> args, int delay, Conditional.SelectionMode matchAll, List<Conditional> conditionals) Creates a new Action -
Method Summary
Modifier and TypeMethodDescriptionboolean
addConditional
(Conditional conditional) Adds a condition to the actionclone()
Gets a copy of the arguments of an actiongetCommand
(@NotNull org.bukkit.entity.Player player) Gets the command that is run to initiate the action.static Action
Gets the action from a serialized stringboolean
removeConditional
(Conditional conditional) Removes a condition from the actiontoJson()
Gets the json equivalent of this action
-
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 performedargs
- The arguments for the Actiondelay
- The amount of ticks to delay an actionmatchAll
- If all the conditions must be met, or oneconditionals
- The conditions to apply to this action
-
-
Method Details
-
getArgsCopy
Gets a copy of the arguments of an action
- Returns:
- A copy of the list of arguments for the actions
-
addConditional
Adds a condition to the action- Parameters:
conditional
- the conditional to add- Returns:
- if the conditional was successfully added
-
removeConditional
Removes a condition from the action- Parameters:
conditional
- conditional to remove- Returns:
- if the condition was successfully removed
-
getCommand
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 improperlyArrayIndexOutOfBoundsException
- if the action was formatted impropperly
-
toJson
Gets the json equivalent of this action
- Returns:
- the serialized version of the action (in json)
-
clone
-