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

  • Method Details

    • parse

      T parse(StringReader reader) throws CommandException
      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

      default String[] getExamples()
      Returns example values for this argument type.

      Used for documentation and error messages.

      Returns:
      an array of example values
    • getResultType

      Class<T> getResultType()
      Returns the Java type this argument parses to.
      Returns:
      the result type class
    • getTypeName

      default String 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")