Class ArgumentWord
java.lang.Object
net.minestom.server.command.builder.arguments.Argument<String>
net.minestom.server.command.builder.arguments.ArgumentWord
Represents a single word in the command.
You can specify the valid words with from(String...)
(do not abuse it or the client will not be able to join).
Example: hey
-
Field Summary
Fields inherited from class net.minestom.server.command.builder.arguments.Argument
allowSpace, CONTAINER, suggestionType, useRemaining
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull ArgumentWord
Used to force the use of a few precise words instead of complete freedom.@Nullable String[]
Gets all the word restrictions.boolean
Gets if this argument allow complete freedom in the word choice or if a list has been defined.byte @Nullable []
@NotNull String
parse
(@NotNull CommandSender sender, @NotNull String input) Parses the given input, and throw anArgumentSyntaxException
if the input cannot be converted toT
parser()
toString()
Methods inherited from class net.minestom.server.command.builder.arguments.Argument
allowSpace, equals, filter, getCallback, getDefaultValue, getId, getSuggestionCallback, hasErrorCallback, hashCode, hasSuggestion, isOptional, map, map, parse, setCallback, setDefaultValue, setDefaultValue, setDefaultValue, setSuggestionCallback, suggestionType, useRemaining
-
Field Details
-
SPACE_ERROR
public static final int SPACE_ERROR- See Also:
-
RESTRICTION_ERROR
public static final int RESTRICTION_ERROR- See Also:
-
restrictions
-
-
Constructor Details
-
ArgumentWord
-
-
Method Details
-
from
Used to force the use of a few precise words instead of complete freedom.WARNING: having an array too long would result in a packet too big or the client being stuck during login.
- Parameters:
restrictions
- the accepted words, can be null but if an array is passed you need to ensure that it is filled with non-null values- Returns:
- 'this' for chaining
- Throws:
NullPointerException
- ifrestrictions
is not null but contains null value(s)
-
parse
@NotNull public @NotNull String parse(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String input) throws ArgumentSyntaxException Description copied from class:Argument
Parses the given input, and throw anArgumentSyntaxException
if the input cannot be converted toT
- Specified by:
parse
in classArgument<String>
- Parameters:
input
- the argument to parse- Returns:
- the parsed argument
- Throws:
ArgumentSyntaxException
- ifvalue
is not valid
-
parser
-
nodeProperties
public byte @Nullable [] nodeProperties()- Overrides:
nodeProperties
in classArgument<String>
-
hasRestrictions
public boolean hasRestrictions()Gets if this argument allow complete freedom in the word choice or if a list has been defined.- Returns:
- true if the word selection is restricted
-
getRestrictions
Gets all the word restrictions.- Returns:
- the word restrictions, can be null
-
toString
-