Class DoubleArgumentType
java.lang.Object
dev.polv.taleapi.command.argument.DoubleArgumentType
- All Implemented Interfaces:
ArgumentType<Double>
Argument type for double values with optional bounds.
Example Usage
// Any double
Command.argument("value", DoubleArgumentType.doubleArg())
// Double >= 0.0
Command.argument("amount", DoubleArgumentType.doubleArg(0.0))
// Double between 0.0 and 1.0
Command.argument("percent", DoubleArgumentType.doubleArg(0.0, 1.0))
-
Method Summary
Modifier and TypeMethodDescriptionstatic DoubleArgumentTypeCreates a double argument type with no bounds.static DoubleArgumentTypedoubleArg(double min) Creates a double argument type with a minimum bound.static DoubleArgumentTypedoubleArg(double min, double max) Creates a double argument type with both bounds.String[]Returns example values for this argument type.doubleReturns the maximum value.doubleReturns the minimum value.Returns the Java type this argument parses to.Returns a human-readable name for this argument type.listSuggestions(CommandContext context, SuggestionsBuilder builder) Provides suggestions for this argument.parse(StringReader reader) Parses the argument from the input string.
-
Method Details
-
doubleArg
Creates a double argument type with no bounds.- Returns:
- a new double argument type
-
doubleArg
Creates a double argument type with a minimum bound.- Parameters:
min- the minimum value (inclusive)- Returns:
- a new double argument type
-
doubleArg
Creates a double argument type with both bounds.- Parameters:
min- the minimum value (inclusive)max- the maximum value (inclusive)- Returns:
- a new double argument type
-
getMinimum
public double getMinimum()Returns the minimum value.- Returns:
- the minimum bound
-
getMaximum
public double getMaximum()Returns the maximum value.- Returns:
- the maximum bound
-
parse
Description copied from interface:ArgumentTypeParses the argument from the input string.- Specified by:
parsein interfaceArgumentType<Double>- 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:ArgumentTypeProvides suggestions for this argument.Default implementation returns no suggestions.
- Specified by:
listSuggestionsin interfaceArgumentType<Double>- Parameters:
context- the current command context (may have partial arguments)builder- the suggestions builder- Returns:
- a future that completes with suggestions
-
getResultType
Description copied from interface:ArgumentTypeReturns the Java type this argument parses to.- Specified by:
getResultTypein interfaceArgumentType<Double>- Returns:
- the result type class
-
getTypeName
Description copied from interface:ArgumentTypeReturns a human-readable name for this argument type.Used in error messages and help text.
- Specified by:
getTypeNamein interfaceArgumentType<Double>- Returns:
- the type name (e.g., "integer", "string", "player")
-
getExamples
Description copied from interface:ArgumentTypeReturns example values for this argument type.Used for documentation and error messages.
- Specified by:
getExamplesin interfaceArgumentType<Double>- Returns:
- an array of example values
-