public final class ArgumentHolder extends Object
Constructor and Description |
---|
ArgumentHolder(String input,
LiteralNode commandStructure) |
Modifier and Type | Method and Description |
---|---|
@NotNull String |
buildUsage() |
@NotNull String |
buildUsage(@Nullable String alias) |
@Nullable IndexRange |
getArgumentIndex(@NotNull String argumentName)
Returns the
IndexRange of the specified argument name, if the argument was defined in
the command structure. |
@NotNull LiteralNode |
getCommandStructure()
Returns the command structure of the arguments held by this argument holder.
|
@NotNull String |
getInput()
Returns the sender argument input.
|
@Nullable Argument |
getLastArgument()
Returns the last argument, for which we have a value.
|
@NotNull String[] |
getRawArgs()
Returns the arguments in their raw state.
|
@Nullable String |
getRawRequiredArgument(@NotNull String argumentName)
Returns the specified required argument's name's argument if is typed in its raw state.
|
<V> V |
getRequiredArgument(@NotNull String name,
@NotNull Class<V> type)
Retrieves the required argument with the specified name, which should be parsed to the
specified type.
|
boolean |
isTyped(@NotNull String argumentName)
Returns whether or not the specified argument is typed (being present when the command was
executed).
|
int |
size()
Returns the arguments length.
|
public ArgumentHolder(String input, LiteralNode commandStructure)
@Nullable public <V> V getRequiredArgument(@NotNull @NotNull String name, @NotNull @NotNull Class<V> type) throws com.mojang.brigadier.exceptions.CommandSyntaxException
V
- value typename
- argument nametype
- argument typecom.mojang.brigadier.exceptions.CommandSyntaxException
@Nullable public @Nullable Argument getLastArgument()
@Nullable public @Nullable IndexRange getArgumentIndex(@NotNull @NotNull String argumentName)
IndexRange
of the specified argument name, if the argument was defined in
the command structure.argumentName
- argument namepublic boolean isTyped(@NotNull @NotNull String argumentName)
argumentName
- the argument's name that you want to check if has value or not.true
if typed, false
otherwise@Nullable public @Nullable String getRawRequiredArgument(@NotNull @NotNull String argumentName) throws com.mojang.brigadier.exceptions.CommandSyntaxException
argumentName
- argument namecom.mojang.brigadier.exceptions.CommandSyntaxException
public int size()
@NotNull public @NotNull String[] getRawArgs()
@NotNull public @NotNull String getInput()
@NotNull public @NotNull LiteralNode getCommandStructure()
@NotNull public @NotNull String buildUsage()
LiteralNode.buildUsage()
@NotNull public @NotNull String buildUsage(@Nullable @Nullable String alias)
alias
- command alias for which you want full command usageLiteralNode.buildUsage(String)
Copyright © 2020. All rights reserved.