CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
com.mojang.brigadier.arguments.LongArgumentType Class Reference

An ArgumentType that parses longs. More...

+ Inheritance diagram for com.mojang.brigadier.arguments.LongArgumentType:

Public Member Functions

long getMinimum ()
 The minimum value an argument is allowed to be (inclusive). More...
 
long getMaximum ()
 The maximal value an argument is allowed to be (inclusive). More...
 
Long parse (final StringReader reader) throws CommandSyntaxException
 
boolean equals (final Object o)
 
int hashCode ()
 
String toString ()
 
Collection< String > getExamples ()
 
default< S > CompletableFuture< SuggestionslistSuggestions (final CommandContext< S > context, final SuggestionsBuilder builder)
 Gets suggestions for a parsed input string on what comes next. More...
 

Static Public Member Functions

static LongArgumentType longArg ()
 A factory method as a simple way to get an instance. More...
 
static LongArgumentType longArg (final long min)
 A factory method as a simple way to get an instance of this class with an enforced minimum value. More...
 
static LongArgumentType longArg (final long min, final long max)
 A factory method as a simple way to get an instance of this class with an enforced minimum and maximum value. More...
 
static long getLong (final CommandContext<?> context, final String name)
 Retrieves the argument with the given name from the context and casts it to a long. More...
 

Detailed Description

An ArgumentType that parses longs.

Allows for numbers in the following format:
(-)?\d+

Member Function Documentation

◆ getLong()

static long com.mojang.brigadier.arguments.LongArgumentType.getLong ( final CommandContext<?>  context,
final String  name 
)
static

Retrieves the argument with the given name from the context and casts it to a long.

Parameters
contextthe context to get the argument from, calls CommandContext#getArgument
namethe name of the argument to retrieve
Returns
the argument as a long
See also
CommandContext::getArgument

◆ getMaximum()

long com.mojang.brigadier.arguments.LongArgumentType.getMaximum ( )

The maximal value an argument is allowed to be (inclusive).

Returns
the maximal value an argument is allowed to be (inclusive)

◆ getMinimum()

long com.mojang.brigadier.arguments.LongArgumentType.getMinimum ( )

The minimum value an argument is allowed to be (inclusive).

Returns
the minimum value an argument is allowed to be (inclusive)

◆ listSuggestions()

default< S > CompletableFuture< Suggestions > com.mojang.brigadier.arguments.ArgumentType< T >.listSuggestions ( final CommandContext< S >  context,
final SuggestionsBuilder  builder 
)
inherited

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
contextthe context to get them for
builderthe 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

◆ longArg() [1/3]

static LongArgumentType com.mojang.brigadier.arguments.LongArgumentType.longArg ( )
static

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", longArg())

Returns
an instance of this argument type

◆ longArg() [2/3]

static LongArgumentType com.mojang.brigadier.arguments.LongArgumentType.longArg ( final long  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", longArg(0))

Parameters
minthe minimal value it needs to be in order to be a valid argument. Inclusive
Returns
an instance of this argument type

◆ longArg() [3/3]

static LongArgumentType com.mojang.brigadier.arguments.LongArgumentType.longArg ( final long  min,
final long  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 Long.MIN_VALUE as minimum.

It is recommended to statically import this method to provide an interface similar to:
argument("name", longArg(0, 100))

Parameters
minthe minimal value it needs to be in order to be a valid argument. Inclusive
maxthe maximal value it needs to be in order to be a valid argument. Inclusive
Returns
an instance of this argument type