Class IntegerArgumentType

java.lang.Object
dev.polv.taleapi.command.argument.IntegerArgumentType
All Implemented Interfaces:
ArgumentType<Integer>

public class IntegerArgumentType extends Object implements ArgumentType<Integer>
Argument type for integer values with optional bounds.

Example Usage


 // Any integer
 Command.argument("count", IntegerArgumentType.integer())

 // Integer >= 0
 Command.argument("amount", IntegerArgumentType.integer(0))

 // Integer between 1 and 100
 Command.argument("level", IntegerArgumentType.integer(1, 100))
 
  • Method Details

    • integer

      public static IntegerArgumentType integer()
      Creates an integer argument type with no bounds.
      Returns:
      a new integer argument type
    • integer

      public static IntegerArgumentType integer(int min)
      Creates an integer argument type with a minimum bound.
      Parameters:
      min - the minimum value (inclusive)
      Returns:
      a new integer argument type
    • integer

      public static IntegerArgumentType integer(int min, int max)
      Creates an integer argument type with both bounds.
      Parameters:
      min - the minimum value (inclusive)
      max - the maximum value (inclusive)
      Returns:
      a new integer argument type
    • getMinimum

      public int getMinimum()
      Returns the minimum value.
      Returns:
      the minimum bound
    • getMaximum

      public int getMaximum()
      Returns the maximum value.
      Returns:
      the maximum bound
    • parse

      public Integer parse(StringReader reader) throws CommandException
      Description copied from interface: ArgumentType
      Parses the argument from the input string.
      Specified by:
      parse in interface ArgumentType<Integer>
      Parameters:
      reader - the string reader positioned at the argument
      Returns:
      the parsed value
      Throws:
      CommandException - if the argument cannot be parsed
    • listSuggestions

      public CompletableFuture<Suggestions> listSuggestions(CommandContext context, SuggestionsBuilder builder)
      Description copied from interface: ArgumentType
      Provides suggestions for this argument.

      Default implementation returns no suggestions.

      Specified by:
      listSuggestions in interface ArgumentType<Integer>
      Parameters:
      context - the current command context (may have partial arguments)
      builder - the suggestions builder
      Returns:
      a future that completes with suggestions
    • getResultType

      public Class<Integer> getResultType()
      Description copied from interface: ArgumentType
      Returns the Java type this argument parses to.
      Specified by:
      getResultType in interface ArgumentType<Integer>
      Returns:
      the result type class
    • getTypeName

      public String getTypeName()
      Description copied from interface: ArgumentType
      Returns a human-readable name for this argument type.

      Used in error messages and help text.

      Specified by:
      getTypeName in interface ArgumentType<Integer>
      Returns:
      the type name (e.g., "integer", "string", "player")
    • getExamples

      public String[] getExamples()
      Description copied from interface: ArgumentType
      Returns example values for this argument type.

      Used for documentation and error messages.

      Specified by:
      getExamples in interface ArgumentType<Integer>
      Returns:
      an array of example values