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
FieldsFields inherited from class net.minestom.server.command.builder.arguments.Argument
allowSpace, CONTAINER, suggestionType, useRemaining -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull ArgumentWordUsed to force the use of a few precise words instead of complete freedom.@Nullable String[]Gets all the word restrictions.booleanGets if this argument allow complete freedom in the word choice or if a list has been defined.byte @Nullable []@NotNull Stringparse(@NotNull CommandSender sender, @NotNull String input) Parses the given input, and throw anArgumentSyntaxExceptionif the input cannot be converted toTparser()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- ifrestrictionsis 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:ArgumentParses the given input, and throw anArgumentSyntaxExceptionif the input cannot be converted toT- Specified by:
parsein classArgument<String>- Parameters:
input- the argument to parse- Returns:
- the parsed argument
- Throws:
ArgumentSyntaxException- ifvalueis not valid
-
parser
-
nodeProperties
public byte @Nullable [] nodeProperties()- Overrides:
nodePropertiesin 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
-