An ArgumentType
that parses integers.
More...
An ArgumentType
that parses integers.
Allows for numbers in the following format:
(-)?\d+
◆ getInteger()
static int com.mojang.brigadier.arguments.IntegerArgumentType.getInteger |
( |
final CommandContext<?> |
context, |
|
|
final String |
name |
|
) |
| |
|
static |
Retrieves the argument with the given name from the context and casts it to an integer.
- Parameters
-
- Returns
- the argument as an integer
- See also
- CommandContext::getArgument
◆ getMaximum()
int com.mojang.brigadier.arguments.IntegerArgumentType.getMaximum |
( |
| ) |
|
The maximal value an argument is allowed to be (inclusive).
- Returns
- the maximal value an argument is allowed to be (inclusive)
◆ getMinimum()
int com.mojang.brigadier.arguments.IntegerArgumentType.getMinimum |
( |
| ) |
|
The minimum value an argument is allowed to be (inclusive).
- Returns
- the minimum value an argument is allowed to be (inclusive)
◆ integer() [1/3]
A factory method as a simple way to get an instance.
It is recommended to statically import this method to provide an interface similar to:
argument("name", integer())
- Returns
- an instance of this argument type
◆ integer() [2/3]
static IntegerArgumentType com.mojang.brigadier.arguments.IntegerArgumentType.integer |
( |
final int |
min | ) |
|
|
static |
A factory method as a simple way to get an instance of this class with an enforced minimum value.
It is recommended to statically import this method to provide an interface similar to:
argument("name", integer(0))
- Parameters
-
min | the minimal value it needs to be in order to be a valid argument. Inclusive |
- Returns
- an instance of this argument type
◆ integer() [3/3]
static IntegerArgumentType com.mojang.brigadier.arguments.IntegerArgumentType.integer |
( |
final int |
min, |
|
|
final int |
max |
|
) |
| |
|
static |
A factory method as a simple way to get an instance of this class with an enforced minimum and maximum value.
If you want to only define a maximum value, use Integer.MIN_VALUE
as minimum.
It is recommended to statically import this method to provide an interface similar to:
argument("name", integer(0, 100))
- Parameters
-
min | the minimal value it needs to be in order to be a valid argument. Inclusive |
max | the maximal value it needs to be in order to be a valid argument. Inclusive |
- Returns
- an instance of this argument type
◆ listSuggestions()
Gets suggestions for a parsed input string on what comes next.
As it is ultimately up to custom argument types to provide suggestions, it may be an asynchronous operation, for example getting in-game data or player names etc. As such, this method returns a future and no guarantees are made to when or how the future completes.
The suggestions provided will be in the context of the end of the parsed input string, but may suggest new or replacement strings for earlier in the input string. For example, if the end of the string was foobar
but an argument preferred it to be minecraft:foobar
, it will suggest a replacement for that whole segment of the input.
- Parameters
-
context | the context to get them for |
builder | the suggestions builder to add them to |
- Returns
- a future that will eventually resolve into a
Suggestions
object @implSpec The default implementation simply returns an empty suggestions object