Interface Parameter
-
- All Known Subinterfaces:
Parameter.Multi
,Parameter.Subcommand
,Parameter.Value<T>
public interface Parameter
Defines how an element of a command argument string should be parsed.Parameters that parse input and return an object into the
CommandContext
should be of typeParameter.Value
in order to maximize type safety. However, there are also other important ways that parameters can be used:firstOfBuilder(Parameter)
allows for multiple parameters that do not have the same return type to attempt to parse an input successfully.seqBuilder(Parameter)
allows for the grouping of multiple parameters that will be executed one after another.Parameter.Subcommand
s can be placed anywhere in a parameter chain where aParameter
can be added, if successfully parsed, any containingCommand
would take precedence and itsCommand.process(CommandCause, ArgumentReader.Mutable)
method will be called instead of any parent.
Parameter
s are intended for use withCommand.Builder
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Parameter.Factory
Contains methods to create the generic builders.static interface
Parameter.FirstOfBuilder
Specifies a builder for creating aParameter
that returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interface
Parameter.Key<T>
static interface
Parameter.Multi
A parameter that consists of multiple parametersstatic interface
Parameter.SequenceBuilder
Specifies a builder for creating aParameter
that returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interface
Parameter.Subcommand
AParameter.Subcommand
represents a literal argument where, if parsed, should indicate to the command processor that theCommandExecutor
of the command should change.static interface
Parameter.Value<T>
Represents aParameter
that attempts to parse an argument to obtain a value of typeT
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Parameter.Value.Builder<java.math.BigDecimal>
bigDecimal()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BIG_DECIMAL
.static Parameter.Value.Builder<java.math.BigInteger>
bigInteger()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BIG_INTEGER
.static Parameter.Value.Builder<BlockState>
blockState()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BLOCK_STATE
.static Parameter.Value.Builder<java.lang.Boolean>
bool()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BOOLEAN
.static <T> Parameter.Value.Builder<T>
builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken)
Gets a builder that builds aParameter.Value
.static <T,V extends ValueParameter<T>>
Parameter.Value.Builder<T>builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken, @NonNull java.util.function.Supplier<V> parameter)
Gets a builder that builds aParameter.Value
.static <T> Parameter.Value.Builder<T>
builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken, @NonNull ValueParameter<? extends T> parameter)
Gets a builder that builds aParameter.Value
.static <T> Parameter.Value.Builder<T>
builder(@NonNull java.lang.Class<T> valueClass)
Gets a builder that builds aParameter.Value
.static <T> Parameter.Value.Builder<T>
builder(@NonNull java.lang.Class<T> valueClass, @NonNull ValueParameter<? extends T> parameter)
Gets a builder that builds aParameter.Value
.static <T,V extends ValueParameter<T>>
Parameter.Value.Builder<T>builder(@NonNull java.lang.Class<T> valueClass, @NonNull DefaultedRegistryReference<V> parameter)
Gets a builder that builds aParameter.Value
.static <T> Parameter.Value.Builder<T>
builder(@NonNull Parameter.Key<T> key)
Gets a builder that builds aParameter.Value
.static <T> Parameter.Value.Builder<T>
choices(@NonNull java.lang.Class<T> returnType, @NonNull java.util.function.Function<java.lang.String,? extends T> valueFunction, @NonNull java.util.function.Supplier<? extends java.util.Collection<java.lang.String>> choices)
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen from.static <T> Parameter.Value.Builder<T>
choices(@NonNull java.lang.Class<T> returnType, @NonNull java.util.Map<java.lang.String,? extends T> choices)
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen from.static Parameter.Value.Builder<java.lang.String>
choices(java.lang.String @NonNull ... choices)
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen fromstatic Parameter.Value.Builder<Color>
color()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.COLOR
.static Parameter.Value.Builder<DataContainer>
dataContainer()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATA_CONTAINER
.static Parameter.Value.Builder<java.time.LocalDateTime>
dateTime()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATE_TIME
.static Parameter.Value.Builder<java.lang.Double>
doubleNumber()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DOUBLE
.static Parameter.Value.Builder<java.time.Duration>
duration()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DURATION
.static Parameter.Value.Builder<Entity>
entity()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
.static Parameter.Value.Builder<Entity>
entityOrTarget()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
static <T extends java.lang.Enum<T>>
Parameter.Value.Builder<T>enumValue(@NonNull java.lang.Class<T> enumClass)
Creates a builder that has aValueParameter
that requires an argument that matches the name of a suppliedEnum
typestatic Parameter
firstOf(@NonNull java.lang.Iterable<Parameter> parameters)
Returns aParameter
that attempts to parse an argument using the supplied parameters in order.static Parameter
firstOf(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters)
Returns aParameter
that attempts to parse an argument using the supplied parameters in order.static Parameter.FirstOfBuilder
firstOfBuilder(@NonNull Parameter parameter)
Returns aParameter.FirstOfBuilder
that allows plugins to attempt to parse an argument using the supplied parameters in order.static Parameter.Value.Builder<Component>
formattingCodeText()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE
.static Parameter.Value.Builder<Component>
formattingCodeTextOfRemainingElements()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL
.static Parameter.Value.Builder<java.lang.Integer>
integerNumber()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.INTEGER
.static Parameter.Value.Builder<java.net.InetAddress>
ip()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.IP
.boolean
isOptional()
Gets whether this parameter is optional.boolean
isTerminal()
Gets whether this parameter is known to be able to be explicitly considered a terminal parameter without regarding its place in a command.static Parameter.Value.Builder<ItemStackSnapshot>
itemStackSnapshot()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT
.static Parameter.Value.Builder<Component>
jsonText()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON
.static Parameter.Value.Builder<Component>
jsonTextOfRemainingElements()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON_ALL
.static <T> Parameter.Key<T>
key(@NonNull java.lang.String key, @NonNull io.leangen.geantyref.TypeToken<T> typeToken)
Creates aParameter.Key
for storing values against.static <T> Parameter.Key<T>
key(@NonNull java.lang.String key, @NonNull java.lang.Class<T> type)
Creates aParameter.Key
for storing values against.static <T> Parameter.Value.Builder<T>
literal(@NonNull java.lang.Class<T> returnType, @NonNull T returnedValue, @NonNull java.util.function.Supplier<? extends java.util.Collection<java.lang.String>> literalSupplier)
Creates a builder that has aValueParameter
that requires an argument to be a literal specifiedstatic <T> Parameter.Value.Builder<T>
literal(@NonNull java.lang.Class<T> returnType, @NonNull T returnedValue, java.lang.String @NonNull ... literal)
Creates a builder that has aValueParameter
that requires an argument to be a literal specifiedstatic Parameter.Value.Builder<ServerLocation>
location()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LOCATION
.static Parameter.Value.Builder<java.lang.Long>
longNumber()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LONG
.static Parameter.Value.Builder<Operator>
operator()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.OPERATOR
.static Parameter.Value.Builder<ServerPlayer>
player()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
.static Parameter.Value.Builder<ServerPlayer>
playerOrTarget()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
, else the targetstatic Parameter.Value.Builder<org.spongepowered.plugin.PluginContainer>
plugin()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLUGIN
.static Parameter.Value.Builder<java.lang.Double>
rangedDouble(double min, double max)
Creates a builder that has theValueParameter
set toVariableValueParameters.doubleRange()
, using the specified bounds (inclusive).static Parameter.Value.Builder<java.lang.Integer>
rangedInteger(int min, int max)
Creates a builder that has theValueParameter
set toVariableValueParameters.integerRange()
, using the specified bounds (inclusive).static <T> Parameter.Value.Builder<T>
registryElement(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull java.util.List<java.util.function.Function<CommandContext,@Nullable RegistryHolder>> holderProviders, @NonNull RegistryType<T> registryKey, @NonNull java.lang.String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameter
that allows you to choose from cataloged types.static <T> Parameter.Value.Builder<T>
registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull java.util.function.Function<CommandContext,@Nullable RegistryHolder> holderProvider, @NonNull RegistryType<T> registryKey, @NonNull java.lang.String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameter
that allows you to choose from cataloged types.static <T> Parameter.Value.Builder<T>
registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull DefaultedRegistryType<T> registryType, @NonNull java.lang.String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameter
that allows you to choose from types registered in a givenRegistry
.static Parameter.Value.Builder<java.lang.String>
remainingJoinedStrings()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS
.static Parameter.Value.Builder<ResourceKey>
resourceKey()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.RESOURCE_KEY
.static Parameter.Value.Builder<Vector3d>
rotation()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ROTATION
.static Parameter
seq(@NonNull java.lang.Iterable<Parameter> parameters)
Returns aParameter
that parses arguments using the supplied parameters in order.static Parameter
seq(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters)
Returns aParameter
that parses arguments using the supplied parameters in order.static Parameter.SequenceBuilder
seqBuilder(@NonNull Parameter parameter)
Returns aParameter.SequenceBuilder
that parses arguments using the supplied parameters in order.static Parameter.Value.Builder<java.lang.String>
string()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.STRING
.static Parameter.Subcommand
subcommand(@NonNull Command.Parameterized subcommand, @NonNull java.lang.String alias, java.lang.String @NonNull ... aliases)
Gets aParameter
that represents a subcommand.static Parameter.Value.Builder<java.net.URL>
url()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.URL
.static Parameter.Value.Builder<java.util.UUID>
user()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.USER
.static Parameter.Value.Builder<java.util.UUID>
uuid()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.UUID
.static Parameter.Value.Builder<Vector3d>
vector3d()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.VECTOR3D
.static Parameter.Value.Builder<ServerWorld>
world()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.WORLD
.
-
-
-
Method Detail
-
key
static <T> Parameter.Key<T> key(@NonNull java.lang.String key, @NonNull io.leangen.geantyref.TypeToken<T> typeToken)
Creates aParameter.Key
for storing values against.- Type Parameters:
T
- The type- Parameters:
key
- The string keytypeToken
- The type of value that this key represents- Returns:
- The
Parameter.Key
-
key
static <T> Parameter.Key<T> key(@NonNull java.lang.String key, @NonNull java.lang.Class<T> type)
Creates aParameter.Key
for storing values against.- Type Parameters:
T
- The type- Parameters:
key
- The string keytype
- The type of value that this key represents. Must not omit any type parameters.- Returns:
- The
Parameter.Key
-
builder
static <T> Parameter.Value.Builder<T> builder(@NonNull java.lang.Class<T> valueClass)
Gets a builder that builds aParameter.Value
.If your parameter type is generic, use
builder(TypeToken)
instead.- Type Parameters:
T
- The type of parameter- Parameters:
valueClass
- The type of value class- Returns:
- The
Parameter.Value.Builder
-
builder
static <T> Parameter.Value.Builder<T> builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken)
Gets a builder that builds aParameter.Value
.- Type Parameters:
T
- The type of parameter- Parameters:
typeToken
- The type of value class as aTypeToken
- Returns:
- The
Parameter.Value.Builder
-
builder
static <T> Parameter.Value.Builder<T> builder(@NonNull Parameter.Key<T> key)
Gets a builder that builds aParameter.Value
.- Type Parameters:
T
- The type of parameter- Parameters:
key
- The key to initialize this builder with- Returns:
- The
Parameter.Value.Builder
-
builder
static <T> Parameter.Value.Builder<T> builder(@NonNull java.lang.Class<T> valueClass, @NonNull ValueParameter<? extends T> parameter)
Gets a builder that builds aParameter.Value
.If your parameter type is generic, use
builder(TypeToken, ValueParameter)
instead.- Type Parameters:
T
- The type of parameter- Parameters:
valueClass
- The type of value class as aClass
parameter
- The value parameter- Returns:
- The
Parameter.Value.Builder
-
builder
static <T> Parameter.Value.Builder<T> builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken, @NonNull ValueParameter<? extends T> parameter)
Gets a builder that builds aParameter.Value
.- Type Parameters:
T
- The type of parameter- Parameters:
typeToken
- The type of value class as aTypeToken
parameter
- The value parameter- Returns:
- The
Parameter.Value.Builder
-
builder
static <T,V extends ValueParameter<T>> Parameter.Value.Builder<T> builder(@NonNull java.lang.Class<T> valueClass, @NonNull DefaultedRegistryReference<V> parameter)
Gets a builder that builds aParameter.Value
.- Type Parameters:
T
- The type of parameterV
- TheValueParameter
to be used as a parser- Parameters:
parameter
- The value parametervalueClass
- The type of value class- Returns:
- The
Parameter.Value.Builder
-
builder
static <T,V extends ValueParameter<T>> Parameter.Value.Builder<T> builder(@NonNull io.leangen.geantyref.TypeToken<T> typeToken, @NonNull java.util.function.Supplier<V> parameter)
Gets a builder that builds aParameter.Value
.- Type Parameters:
T
- The type of parameterV
- TheValueParameter
to be used as a parser- Parameters:
parameter
- The value parametertypeToken
- The type of value class as aTypeToken
- Returns:
- The
Parameter.Value.Builder
-
subcommand
static Parameter.Subcommand subcommand(@NonNull Command.Parameterized subcommand, @NonNull java.lang.String alias, java.lang.String @NonNull ... aliases)
Gets aParameter
that represents a subcommand.If a
Parameter.Subcommand
alias in a parameter chain is successfully matched, then element parsing will continue with the parameters supplied toCommand
. It is implementation dependent as to what happens if a subcommand fails to parse.- Parameters:
subcommand
- TheCommand
to executealias
- The first alias of the subcommandaliases
- Subsequent aliases, if any- Returns:
- The
Parameter.Subcommand
for use in aParameter
chain
-
firstOfBuilder
static Parameter.FirstOfBuilder firstOfBuilder(@NonNull Parameter parameter)
Returns aParameter.FirstOfBuilder
that allows plugins to attempt to parse an argument using the supplied parameters in order. Once a parameter has parsed the argument successfully, no more parameters supplied here will be attempted.- Parameters:
parameter
- The firstParameter
- Returns:
- The
Parameter.FirstOfBuilder
to continue chaining
-
firstOf
static Parameter firstOf(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters)
Returns aParameter
that attempts to parse an argument using the supplied parameters in order. Once a parameter has parsed the argument successfully, no more parameters supplied here will be attempted.
-
firstOf
static Parameter firstOf(@NonNull java.lang.Iterable<Parameter> parameters)
Returns aParameter
that attempts to parse an argument using the supplied parameters in order. Once a parameter has parsed the argument successfully, no more parameters supplied here will be attempted.
-
seqBuilder
static Parameter.SequenceBuilder seqBuilder(@NonNull Parameter parameter)
Returns aParameter.SequenceBuilder
that parses arguments using the supplied parameters in order.- Parameters:
parameter
- The firstParameter
in the sequence- Returns:
- The
Parameter.SequenceBuilder
, to continue building the chain
-
seq
static Parameter seq(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters)
Returns aParameter
that parses arguments using the supplied parameters in order.
-
seq
static Parameter seq(@NonNull java.lang.Iterable<Parameter> parameters)
Returns aParameter
that parses arguments using the supplied parameters in order.
-
bigDecimal
static Parameter.Value.Builder<java.math.BigDecimal> bigDecimal()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BIG_DECIMAL
.- Returns:
- A
Parameter.Value.Builder
-
bigInteger
static Parameter.Value.Builder<java.math.BigInteger> bigInteger()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BIG_INTEGER
.- Returns:
- A
Parameter.Value.Builder
-
blockState
static Parameter.Value.Builder<BlockState> blockState()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BLOCK_STATE
.- Returns:
- A
Parameter.Value.Builder
-
bool
static Parameter.Value.Builder<java.lang.Boolean> bool()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.BOOLEAN
.- Returns:
- A
Parameter.Value.Builder
-
color
static Parameter.Value.Builder<Color> color()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.COLOR
.- Returns:
- A
Parameter.Value.Builder
-
dataContainer
static Parameter.Value.Builder<DataContainer> dataContainer()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATA_CONTAINER
.- Returns:
- A
Parameter.Value.Builder
-
dateTime
static Parameter.Value.Builder<java.time.LocalDateTime> dateTime()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DATE_TIME
.- Returns:
- A
Parameter.Value.Builder
-
duration
static Parameter.Value.Builder<java.time.Duration> duration()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DURATION
.- Returns:
- A
Parameter.Value.Builder
-
doubleNumber
static Parameter.Value.Builder<java.lang.Double> doubleNumber()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.DOUBLE
.- Returns:
- A
Parameter.Value.Builder
-
entity
static Parameter.Value.Builder<Entity> entity()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
.- Returns:
- A
Parameter.Value.Builder
-
entityOrTarget
static Parameter.Value.Builder<Entity> entityOrTarget()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ENTITY
- Returns:
- A
Parameter.Value.Builder
-
formattingCodeText
static Parameter.Value.Builder<Component> formattingCodeText()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE
.- Returns:
- A
Parameter.Value.Builder
-
formattingCodeTextOfRemainingElements
static Parameter.Value.Builder<Component> formattingCodeTextOfRemainingElements()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL
.- Returns:
- A
Parameter.Value.Builder
-
integerNumber
static Parameter.Value.Builder<java.lang.Integer> integerNumber()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.INTEGER
.- Returns:
- A
Parameter.Value.Builder
-
ip
static Parameter.Value.Builder<java.net.InetAddress> ip()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.IP
.- Returns:
- A
Parameter.Value.Builder
-
itemStackSnapshot
static Parameter.Value.Builder<ItemStackSnapshot> itemStackSnapshot()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT
.- Returns:
- A
Parameter.Value.Builder
-
jsonText
static Parameter.Value.Builder<Component> jsonText()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON
.- Returns:
- A
Parameter.Value.Builder
-
jsonTextOfRemainingElements
static Parameter.Value.Builder<Component> jsonTextOfRemainingElements()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.TEXT_JSON_ALL
.- Returns:
- A
Parameter.Value.Builder
-
location
static Parameter.Value.Builder<ServerLocation> location()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LOCATION
.- Returns:
- A
Parameter.Value.Builder
-
longNumber
static Parameter.Value.Builder<java.lang.Long> longNumber()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.LONG
.- Returns:
- A
Parameter.Value.Builder
-
operator
static Parameter.Value.Builder<Operator> operator()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.OPERATOR
.- Returns:
- A
Parameter.Value.Builder
-
player
static Parameter.Value.Builder<ServerPlayer> player()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
.- Returns:
- A
Parameter.Value.Builder
-
playerOrTarget
static Parameter.Value.Builder<ServerPlayer> playerOrTarget()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLAYER
, else the target- Returns:
- A
Parameter.Value.Builder
-
plugin
static Parameter.Value.Builder<org.spongepowered.plugin.PluginContainer> plugin()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.PLUGIN
.- Returns:
- A
Parameter.Value.Builder
-
rangedDouble
static Parameter.Value.Builder<java.lang.Double> rangedDouble(double min, double max)
Creates a builder that has theValueParameter
set toVariableValueParameters.doubleRange()
, using the specified bounds (inclusive).- Parameters:
min
- The minimum value.max
- The maximum value.- Returns:
- A
Parameter.Value.Builder
-
rangedInteger
static Parameter.Value.Builder<java.lang.Integer> rangedInteger(int min, int max)
Creates a builder that has theValueParameter
set toVariableValueParameters.integerRange()
, using the specified bounds (inclusive).- Parameters:
min
- The minimum value.max
- The maximum value.- Returns:
- A
Parameter.Value.Builder
-
remainingJoinedStrings
static Parameter.Value.Builder<java.lang.String> remainingJoinedStrings()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS
.- Returns:
- A
Parameter.Value.Builder
-
resourceKey
static Parameter.Value.Builder<ResourceKey> resourceKey()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.RESOURCE_KEY
.- Returns:
- A
Parameter.Value.Builder
-
rotation
static Parameter.Value.Builder<Vector3d> rotation()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.ROTATION
.- Returns:
- A
Parameter.Value.Builder
-
string
static Parameter.Value.Builder<java.lang.String> string()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.STRING
.- Returns:
- A
Parameter.Value.Builder
-
url
static Parameter.Value.Builder<java.net.URL> url()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.URL
.- Returns:
- A
Parameter.Value.Builder
-
user
static Parameter.Value.Builder<java.util.UUID> user()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.USER
.- Returns:
- A
Parameter.Value.Builder
-
uuid
static Parameter.Value.Builder<java.util.UUID> uuid()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.UUID
.- Returns:
- A
Parameter.Value.Builder
-
vector3d
static Parameter.Value.Builder<Vector3d> vector3d()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.VECTOR3D
.- Returns:
- A
Parameter.Value.Builder
-
world
static Parameter.Value.Builder<ServerWorld> world()
Creates a builder that has theValueParameter
set toResourceKeyedValueParameters.WORLD
.- Returns:
- A
Parameter.Value.Builder
-
registryElement
static <T> Parameter.Value.Builder<T> registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull java.util.function.Function<CommandContext,@Nullable RegistryHolder> holderProvider, @NonNull RegistryType<T> registryKey, @NonNull java.lang.String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameter
that allows you to choose from cataloged types.See
#defaultNamespace(String)
for how default namespaces work.If the
Game
orServer
scopedRegistryHolder
is required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDER
orVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDER
may be used.- Type Parameters:
T
- The type of registry value- Parameters:
type
- The registry value type to check for choicesholderProvider
- AFunction
that provides the appropriateRegistryHolder
to get the appropriateRegistry
registryKey
- TheRegistryKey
that represents the targetRegistry
defaultNamespaces
- The default namespaces that will be used with the provided value if the supplied argument is un-namespaced- Returns:
- A
Parameter.Value.Builder
-
registryElement
static <T> Parameter.Value.Builder<T> registryElement(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull java.util.List<java.util.function.Function<CommandContext,@Nullable RegistryHolder>> holderProviders, @NonNull RegistryType<T> registryKey, @NonNull java.lang.String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameter
that allows you to choose from cataloged types.See
#defaultNamespace(String)
for how default namespaces work.If the
Game
orServer
scopedRegistryHolder
is required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDER
orVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDER
may be used.- Type Parameters:
T
- The type of registry value- Parameters:
type
- The registry value type to check for choicesholderProviders
-Function
s that provides the appropriateRegistryHolder
to get the appropriateRegistry
registryKey
- TheRegistryKey
that represents the targetRegistry
defaultNamespaces
- The default namespaces that will be used with the provided value if the supplied argument is un-namespaced- Returns:
- A
Parameter.Value.Builder
-
registryElement
static <T> Parameter.Value.Builder<T> registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull DefaultedRegistryType<T> registryType, @NonNull java.lang.String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameter
that allows you to choose from types registered in a givenRegistry
.See
#defaultNamespace(String)
for how default namespaces work.- Type Parameters:
T
- The type of registyr value- Parameters:
type
- The registry value type to check for choicesregistryType
- TheDefaultedRegistryType
to use when retrieving objectsdefaultNamespaces
- The default namespaces that will be used with the provided value if the supplied argument is un-namespaced- Returns:
- A
Parameter.Value.Builder
-
choices
static Parameter.Value.Builder<java.lang.String> choices(java.lang.String @NonNull ... choices)
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen fromThis will return a parser that will return
String
s- Parameters:
choices
- The choices- Returns:
- A
Parameter.Value.Builder
-
choices
static <T> Parameter.Value.Builder<T> choices(@NonNull java.lang.Class<T> returnType, @NonNull java.util.Map<java.lang.String,? extends T> choices)
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContext
when a choice is selected.- Type Parameters:
T
- The type of parameter- Parameters:
returnType
- The type of object that will be returned by the parser to be built by this builder.choices
- The choices- Returns:
- A
Parameter.Value.Builder
-
choices
static <T> Parameter.Value.Builder<T> choices(@NonNull java.lang.Class<T> returnType, @NonNull java.util.function.Function<java.lang.String,? extends T> valueFunction, @NonNull java.util.function.Supplier<? extends java.util.Collection<java.lang.String>> choices)
Creates a builder that has aValueParameter
that allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContext
when a choice is selected, through the use of thevalueFunction
.- Type Parameters:
T
- The type of parameter- Parameters:
returnType
- The type of object that will be returned by the parser to be built by this builder.valueFunction
- The function that returns an object to put in theCommandContext
based on the supplied choicechoices
- The choices- Returns:
- A
Parameter.Value.Builder
-
enumValue
static <T extends java.lang.Enum<T>> Parameter.Value.Builder<T> enumValue(@NonNull java.lang.Class<T> enumClass)
Creates a builder that has aValueParameter
that requires an argument that matches the name of a suppliedEnum
type- Type Parameters:
T
- The type ofEnum
- Parameters:
enumClass
- TheEnum
class type- Returns:
- A
Parameter.Value.Builder
-
literal
static <T> Parameter.Value.Builder<T> literal(@NonNull java.lang.Class<T> returnType, @NonNull T returnedValue, java.lang.String @NonNull ... literal)
Creates a builder that has aValueParameter
that requires an argument to be a literal specified- Type Parameters:
T
- The type of value- Parameters:
returnType
- The type of object that will be returned by the parser to be built by this builder.returnedValue
- The object to put in theCommandContext
if the literal matches.literal
- The literal to match- Returns:
- A
Parameter.Value.Builder
-
literal
static <T> Parameter.Value.Builder<T> literal(@NonNull java.lang.Class<T> returnType, @NonNull T returnedValue, @NonNull java.util.function.Supplier<? extends java.util.Collection<java.lang.String>> literalSupplier)
Creates a builder that has aValueParameter
that requires an argument to be a literal specified- Type Parameters:
T
- The type of parameter- Parameters:
returnedValue
- The object to put in theCommandContext
if the literal matchesliteralSupplier
- A function that provies the literal to match at invocationreturnType
- The type of return- Returns:
- A
Parameter.Value.Builder
-
isOptional
boolean isOptional()
Gets whether this parameter is optional.An optional parameter will not throw an exception if it cannot parse an input, instead passing control to another parameter.
- Returns:
- true if optional, else false.
-
isTerminal
boolean isTerminal()
Gets whether this parameter is known to be able to be explicitly considered a terminal parameter without regarding its place in a command.A terminal parameter will pass control to the command's associated
CommandExecutor
if the parameter consumes the end of an input string.Because this parameter may be reused across multiple commands, there may be some circumstances where this parameter will act as a terminal parameter but this is false, such as when this is at the end of a parameter chain or the following parameters are all optional. The return value from this method generally will return whether this element is terminal without regard to other parameters in a command.
- Returns:
- true if known to be terminal.
-
-