Record Class CommandArguments
- Record Components:
args- The arguments for this commandargsMap- The arguments for this command mapped to their node names. This is an ordered maprawArgs- The raw arguments for this command.rawArgsMap- The raw arguments for this command mapped to their node names. This is an ordered mapfullInput- The command string a player has entered (including the /)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObject[]args()Returns the value of theargsrecord component.argsMap()Returns the value of theargsMaprecord component.intcount()booleanIndicates whether some other object is "equal to" this one.Returns the value of thefullInputrecord component.get(int index) Returns an argument by its positionReturns an argument by its node name<T> TgetByArgument(AbstractArgument<T, ?, ?, ?> argumentType) Returns an argument purely based on its CommandAPI representation.<T> TgetByArgumentOrDefault(AbstractArgument<T, ?, ?, ?> argumentType, T defaultValue) Returns an argument purely based on its CommandAPI representation or a default value if the argument wasn't found.<T> TgetByClass(int index, Class<T> argumentType) Returns an argument based on its index.<T> TgetByClass(String nodeName, Class<T> argumentType) Returns an argument based on its node name.<T> TgetByClassOrDefault(int index, Class<T> argumentType, T defaultValue) Returns an argument based on its index or a default value if the argument wasn't found.<T> TgetByClassOrDefault(String nodeName, Class<T> argumentType, T defaultValue) Returns an argument based on its node name or a default value if the argument wasn't found.Deprecated, for removal: This API element is subject to removal in a future version.getOptional(int index) Returns anOptionalholding the argument by its indexgetOptional(String nodeName) Returns an argument by its node name<T> Optional<T> getOptionalByArgument(AbstractArgument<T, ?, ?, ?> argumentType) Returns anOptionalholding the provided argument.<T> Optional<T> getOptionalByClass(int index, Class<T> argumentType) Returns anOptionalholding the argument at the given index.<T> Optional<T> getOptionalByClass(String nodeName, Class<T> argumentType) Returns anOptionalholding the argument with the given 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) Returns an argument by its indexgetOrDefault(int index, Supplier<?> defaultValue) Returns an argument by its indexgetOrDefault(String nodeName, Object defaultValue) Returns an argument by its node namegetOrDefault(String nodeName, Supplier<?> defaultValue) Returns an argument by its node namegetOrDefaultRaw(int index, String defaultValue) Returns a raw argument by its indexgetOrDefaultRaw(int index, Supplier<String> defaultValue) Returns a raw argument by its indexgetOrDefaultRaw(String nodeName, String defaultValue) Returns a raw argument by its node namegetOrDefaultRaw(String nodeName, Supplier<String> defaultValue) Returns a raw argument by its node name<T> TgetOrDefaultUnchecked(int index, Supplier<T> defaultValue) Returns an argument by its index<T> TgetOrDefaultUnchecked(int index, T defaultValue) Returns an argument by its index<T> TgetOrDefaultUnchecked(String nodeName, Supplier<T> defaultValue) Returns an argument by its node name<T> TgetOrDefaultUnchecked(String nodeName, T defaultValue) Returns an argument by its node namegetRaw(int index) Returns a raw argument by its positionReturns a raw argument by its node namegetRawOptional(int index) Returns anOptionalholding the raw argument by its indexgetRawOptional(String nodeName) Returns anOptionalholding the raw argument by its node name<T> TgetUnchecked(int index) Returns an argument by its position<T> TgetUnchecked(String nodeName) Returns an argument by its node nameinthashCode()Returns a hash code value for this object.String[]rawArgs()Returns the value of therawArgsrecord component.Returns the value of therawArgsMaprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CommandArguments
public CommandArguments(Object[] args, Map<String, Object> argsMap, String[] rawArgs, Map<String, String> rawArgsMap, String fullInput) Creates an instance of aCommandArgumentsrecord class.- Parameters:
args- the value for theargsrecord componentargsMap- the value for theargsMaprecord componentrawArgs- the value for therawArgsrecord componentrawArgsMap- the value for therawArgsMaprecord componentfullInput- the value for thefullInputrecord component
-
-
Method Details
-
argsMap
-
rawArgsMap
Returns the value of therawArgsMaprecord component.- Returns:
- the value of the
rawArgsMaprecord component
-
getFullInput
Deprecated, for removal: This API element is subject to removal in a future version.This method has been deprecated in favour offullInput()This returns the raw command string a player has entered- Returns:
- The raw command string a player has entered
-
count
public int count()- Returns:
- The number of arguments for this command
-
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
-
getOrDefault
-
getOrDefault
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
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
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
-
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
-
getRaw
Returns a raw argument by its positionA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- 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.
-
getRaw
Returns a raw argument by its node nameA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- Parameters:
nodeName- The node name of this argument. This was set when initializing an argument- Returns:
- A raw argument which has the given node name. Can be
nullifnodeNamewas not found.
-
getOrDefaultRaw
Returns a raw argument by its indexA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- Parameters:
index- The position of this argumentdefaultValue- The String returned if the raw argument is not existent- Returns:
- A raw argument which is placed at the given index, or the provided default value
-
getOrDefaultRaw
Returns a raw argument by its node nameA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- Parameters:
nodeName- The node name of this argument. This was set when initializing an argumentdefaultValue- The String returned if the raw argument was not found.- Returns:
- A raw argument with the specified node name or the provided default value
-
getOrDefaultRaw
Returns a raw argument by its indexA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- Parameters:
index- The position of this argumentdefaultValue- The String returned if the raw argument is not existent- Returns:
- A raw argument which is placed at the given index, or the provided default value
-
getOrDefaultRaw
Returns a raw argument by its node nameA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- Parameters:
nodeName- The node name of this raw argument. This was set when initializing an argumentdefaultValue- The String returned if the raw argument was not found.- Returns:
- A raw argument with the specified node name or the provided default value
-
getRawOptional
Returns anOptionalholding the raw argument by its indexA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- Parameters:
index- The position of this argument- Returns:
- An optional holding the raw argument which is placed at the given index, or an empty optional if index is invalid
-
getRawOptional
Returns anOptionalholding the raw argument by its node nameA raw argument is the
Stringform of an argument as written in a command. For example take this command:/mycommand @e 15.3When using this method to access these arguments,
@eand15.3will be available asStrings and not as aCollectionandDouble- 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
public <T> T getOrDefaultUnchecked(int index, T defaultValue) 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
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
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
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
-
getByArgument
Returns an argument purely based on its CommandAPI representation. This also attempts to directly cast the argument to the type represented byAbstractArgument.getPrimitiveType()- Parameters:
argumentType- The argument instance used to create the argument- Returns:
- The argument represented by the CommandAPI argument, or null if the argument was not found.
-
getByArgumentOrDefault
Returns an argument purely based on its CommandAPI representation or a default value if the argument wasn't found.If the argument was found, this also attempts to directly cast the argument to the type represented by
AbstractArgument.getPrimitiveType()- Parameters:
argumentType- The argument instance used to create the argumentdefaultValue- The default value to return if the argument wasn't found- Returns:
- The argument represented by the CommandAPI argument, or the default value if the argument was not found.
-
getOptionalByArgument
Returns anOptionalholding the provided argument. ThisOptionalcan be empty if the argument was not given when running the command.This attempts to directly cast the argument to the type represented by
AbstractArgument.getPrimitiveType()- Parameters:
argumentType- The argument instance used to create the argument- Returns:
- An
Optionalholding the argument, or an emptyOptionalif the argument was not found.
-
getByClass
Returns an argument based on its node name. This also attempts to directly cast the argument to the type represented by theargumentTypeparameter.- Parameters:
nodeName- The node name of the argumentargumentType- The class that represents the argument- Returns:
- The argument with the given node name, or null if the argument was not found.
-
getByClassOrDefault
Returns an argument based on its node name or a default value if the argument wasn't found.If the argument was found, this method attempts to directly cast the argument to the type represented by the
argumentTypeparameter.- Parameters:
nodeName- The node name of the argumentargumentType- The class that represents the argumentdefaultValue- The default value to return if the argument wasn't found- Returns:
- The argument with the given node name, or the default value if the argument was not found.
-
getOptionalByClass
Returns anOptionalholding the argument with the given node name. ThisOptionalcan be empty if the argument was not given when running the command.This attempts to directly cast the argument to the type represented by the
argumentTypeparameter.- Parameters:
nodeName- The node name of the argumentargumentType- The class that represents the argument- Returns:
- An
Optionalholding the argument, or an emptyOptionalif the argument was not found.
-
getByClass
Returns an argument based on its index. This also attempts to directly cast the argument to the type represented by theargumentTypeparameter.- Parameters:
index- The index of the argumentargumentType- The class that represents the argument- Returns:
- The argument at the given index, or null if the argument was not found.
-
getByClassOrDefault
Returns an argument based on its index or a default value if the argument wasn't found.If the argument was found, this method attempts to directly cast the argument to the type represented by the
argumentTypeparameter.- Parameters:
index- The index of the argumentargumentType- The class that represents the argumentdefaultValue- The default value to return if the argument wasn't found- Returns:
- The argument at the given index, or the default value if the argument was not found.
-
getOptionalByClass
Returns anOptionalholding the argument at the given index. ThisOptionalcan be empty if the argument was not given when running the command.This attempts to directly cast the argument to the type represented by the
argumentTypeparameter.- Parameters:
index- The index of the argumentargumentType- The class that represents the argument- Returns:
- An
Optionalholding the argument, or an emptyOptionalif the argument was not found.
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
toString
-
args
-
rawArgs
-
fullInput
-
fullInput()