Package dev.jorel.commandapi.executors
Class CommandArguments
java.lang.Object
dev.jorel.commandapi.executors.CommandArguments
This class stores the arguments for this command
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObject[]args()argsMap()intcount()get(int index) Returns an argument by its positionReturns an argument by its node nameThis returns the raw command string a player has enteredgetOptional(int index) Returns anOptionalholding the argument by its indexgetOptional(String nodeName) Returns an argument by its node name<T> Optional<T>getOptionalUnchecked(int index) Returns anOptionalholding the argument at its index<T> Optional<T>getOptionalUnchecked(String nodeName) Returns anOptionalholding the argument by its node namegetOrDefault(int index, Object defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.getOrDefault(int index, Supplier<?> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptional(int)getOrDefault(String nodeName, Object defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptional(String)getOrDefault(String nodeName, Supplier<?> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptional(String)<T> TgetOrDefaultUnchecked(int index, Supplier<T> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(int)<T> TgetOrDefaultUnchecked(int index, T defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(int)<T> TgetOrDefaultUnchecked(String nodeName, Supplier<T> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(String)<T> TgetOrDefaultUnchecked(String nodeName, T defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(String)<T> TgetUnchecked(int index) Returns an argument by its position<T> TgetUnchecked(String nodeName) Returns an argument by its node name
-
Constructor Details
-
CommandArguments
Constructs a new CommandArguments instance- Parameters:
args- The arguments for this commandargsMap- The arguments for this command mapped to the node names. This is an ordered mapfullInput- The raw command a player has entered
-
-
Method Details
-
args
- Returns:
- The complete argument array of this command
-
argsMap
- Returns:
- An unmodifiable clone of the mapping of node names to argument values
-
count
public int count()- Returns:
- The number of arguments in this object
-
get
Returns an argument by its position- Parameters:
index- The position of this argument- Returns:
- An argument which is placed at the given index, or
nullif the provided index does not point to an argument.
-
get
Returns an argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argument- Returns:
- An argument which has the given node name. Can be null if
nodeNamewas not found.
-
getFullInput
This returns the raw command string a player has entered- Returns:
- The raw command string a player has entered
-
getOrDefault
@Deprecated(since="9.0.1", forRemoval=true) public Object getOrDefault(int index, Object defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptional(int)Returns an argument by its index- Parameters:
index- The position of this argumentdefaultValue- The Object returned if the argument is not existent- Returns:
- An argument which is placed at the given index, or the provided default value
-
getOrDefault
@Deprecated(since="9.0.1", forRemoval=true) public Object getOrDefault(String nodeName, Object defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptional(String)Returns an argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argumentdefaultValue- The Object returned if the argument was not found.- Returns:
- The argument with the specified node name or the provided default value
-
getOrDefault
@Deprecated(since="9.0.1", forRemoval=true) public Object getOrDefault(int index, Supplier<?> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptional(int)Returns an argument by its index- Parameters:
index- The position of this argumentdefaultValue- The Object returned if the argument is not existent- Returns:
- An argument which is placed at the given index, or the provided default value
-
getOrDefault
@Deprecated(since="9.0.1", forRemoval=true) public Object getOrDefault(String nodeName, Supplier<?> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptional(String)Returns an argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argumentdefaultValue- The Object returned if the argument was not found.- Returns:
- The argument with the specified node name or the provided default value
-
getOptional
Returns anOptionalholding the argument by its index- Parameters:
index- The position of this argument- Returns:
- An optional holding the argument which is placed at the given index, or an empty optional if index is invalid
-
getOptional
Returns an argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argument- Returns:
- An optional holding the argument with the specified node name or an empty optional if the node name was not found
-
getUnchecked
@Nullable public <T> T getUnchecked(int index) Returns an argument by its position- Parameters:
index- The position of this argument- Returns:
- An argument which is placed at the given index, or
nullif the provided index does not point to an argument.
-
getUnchecked
Returns an argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argument- Returns:
- An argument which has the given node name. Can be null if
nodeNamewas not found.
-
getOrDefaultUnchecked
@Deprecated(since="9.0.1", forRemoval=true) public <T> T getOrDefaultUnchecked(int index, T defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(int)Returns an argument by its index- Parameters:
index- The position of this argumentdefaultValue- The Object returned if the argument is not existent- Returns:
- An argument which is placed at the given index, or the provided default value
-
getOrDefaultUnchecked
@Deprecated(since="9.0.1", forRemoval=true) public <T> T getOrDefaultUnchecked(String nodeName, T defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(String)Returns an argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argumentdefaultValue- The Object returned if the argument was not found.- Returns:
- The argument with the specified node name or the provided default value
-
getOrDefaultUnchecked
@Deprecated(since="9.0.1", forRemoval=true) public <T> T getOrDefaultUnchecked(int index, Supplier<T> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(int)Returns an argument by its index- Parameters:
index- The position of this argumentdefaultValue- The Object returned if the argument is not existent- Returns:
- An argument which is placed at the given index, or the provided default value
-
getOrDefaultUnchecked
@Deprecated(since="9.0.1", forRemoval=true) public <T> T getOrDefaultUnchecked(String nodeName, Supplier<T> defaultValue) Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated! Please usegetOptionalUnchecked(String)Returns an argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argumentdefaultValue- The Object returned if the argument was not found.- Returns:
- The argument with the specified node name or the provided default value
-
getOptionalUnchecked
Returns anOptionalholding the argument at its index- Parameters:
index- The position of this argument- Returns:
- An optional holding the argument at its index, or an empty optional if the index was invalid
-
getOptionalUnchecked
Returns anOptionalholding the argument by its node name- Parameters:
nodeName- The node name of this argument. This was set when initializing an argument- Returns:
- An optional holding the argument with the specified node name, or an empty optional if the index was invalid
-
getOptional(int)