Interface ArgumentType<T>
- Type Parameters:
T- the type this argument parses to
- All Known Implementing Classes:
BooleanArgumentType,DoubleArgumentType,FloatArgumentType,IntegerArgumentType,LongArgumentType,StringArgumentType
public interface ArgumentType<T>
Defines how to parse and suggest a command argument.
Each argument type knows how to:
- Parse a string input into a typed value
- Provide tab-completion suggestions
- Describe the expected format for error messages
Built-in Types
StringArgumentType- String arguments (word, greedy, quoted)IntegerArgumentType- Integer arguments with optional boundsDoubleArgumentType- Double arguments with optional boundsBooleanArgumentType- Boolean arguments (true/false)
-
Method Summary
Modifier and TypeMethodDescriptiondefault String[]Returns example values for this argument type.Returns the Java type this argument parses to.default StringReturns a human-readable name for this argument type.default CompletableFuture<Suggestions>listSuggestions(CommandContext context, SuggestionsBuilder builder) Provides suggestions for this argument.parse(StringReader reader) Parses the argument from the input string.
-
Method Details
-
parse
Parses the argument from the input string.- Parameters:
reader- the string reader positioned at the argument- Returns:
- the parsed value
- Throws:
CommandException- if the argument cannot be parsed
-
listSuggestions
default CompletableFuture<Suggestions> listSuggestions(CommandContext context, SuggestionsBuilder builder) Provides suggestions for this argument.Default implementation returns no suggestions.
- Parameters:
context- the current command context (may have partial arguments)builder- the suggestions builder- Returns:
- a future that completes with suggestions
-
getExamples
Returns example values for this argument type.Used for documentation and error messages.
- Returns:
- an array of example values
-
getResultType
Returns the Java type this argument parses to.- Returns:
- the result type class
-
getTypeName
Returns a human-readable name for this argument type.Used in error messages and help text.
- Returns:
- the type name (e.g., "integer", "string", "player")
-