Interface Parameter
-
- All Known Subinterfaces:
Parameter.Multi,Parameter.Subcommand,Parameter.Value<T>
public interface ParameterDefines how an element of a command argument string should be parsed.Parameters that parse input and return an object into the
CommandContextshould be of typeParameter.Valuein 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.Subcommands can be placed anywhere in a parameter chain where aParametercan be added, if successfully parsed, any containingCommandwould take precedence and itsCommand.process(CommandCause, ArgumentReader.Mutable)method will be called instead of any parent.
Parameters are intended for use withCommand.Builders.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceParameter.FactoryContains methods to create the generic builders.static interfaceParameter.FirstOfBuilderSpecifies a builder for creating aParameterthat returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interfaceParameter.Key<T>static interfaceParameter.MultiA parameter that consists of multiple parametersstatic interfaceParameter.SequenceBuilderSpecifies a builder for creating aParameterthat returns a parameter that concatenates all parameters into a single parameter to be executed one by one.static interfaceParameter.SubcommandAParameter.Subcommandrepresents a literal argument where, if parsed, should indicate to the command processor that theCommandExecutorof the command should change.static interfaceParameter.Value<T>Represents aParameterthat 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<BigDecimal>bigDecimal()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_DECIMAL.static Parameter.Value.Builder<BigInteger>bigInteger()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_INTEGER.static Parameter.Value.Builder<BlockState>blockState()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BLOCK_STATE.static Parameter.Value.Builder<Boolean>bool()Creates a builder that has theValueParameterset 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 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 Class<T> valueClass)Gets a builder that builds aParameter.Value.static <T> Parameter.Value.Builder<T>builder(@NonNull 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 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 Class<T> returnType, @NonNull Function<String,? extends T> valueFunction, @NonNull Supplier<? extends Collection<String>> choices)Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from.static <T> Parameter.Value.Builder<T>choices(@NonNull Class<T> returnType, @NonNull Map<String,? extends T> choices)Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from.static Parameter.Value.Builder<String>choices(String @NonNull ... choices)Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen fromstatic Parameter.Value.Builder<Color>color()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.COLOR.static Parameter.Value.Builder<DataContainer>dataContainer()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATA_CONTAINER.static Parameter.Value.Builder<LocalDateTime>dateTime()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATE_TIME.static Parameter.Value.Builder<Double>doubleNumber()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DOUBLE.static Parameter.Value.Builder<Duration>duration()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DURATION.static Parameter.Value.Builder<Entity>entity()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITY.static Parameter.Value.Builder<Entity>entityOrTarget()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITYstatic <T extends Enum<T>>
Parameter.Value.Builder<T>enumValue(@NonNull Class<T> enumClass)Creates a builder that has aValueParameterthat requires an argument that matches the name of a suppliedEnumtypestatic ParameterfirstOf(@NonNull Iterable<Parameter> parameters)Returns aParameterthat attempts to parse an argument using the supplied parameters in order.static ParameterfirstOf(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters)Returns aParameterthat attempts to parse an argument using the supplied parameters in order.static Parameter.FirstOfBuilderfirstOfBuilder(@NonNull Parameter parameter)Returns aParameter.FirstOfBuilderthat 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 theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE.static Parameter.Value.Builder<Component>formattingCodeTextOfRemainingElements()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL.static Parameter.Value.Builder<Integer>integerNumber()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.INTEGER.static Parameter.Value.Builder<InetAddress>ip()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.IP.booleanisOptional()Gets whether this parameter is optional.booleanisTerminal()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 theValueParameterset toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT.static Parameter.Value.Builder<Component>jsonText()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON.static Parameter.Value.Builder<Component>jsonTextOfRemainingElements()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON_ALL.static <T> Parameter.Key<T>key(@NonNull String key, @NonNull io.leangen.geantyref.TypeToken<T> typeToken)Creates aParameter.Keyfor storing values against.static <T> Parameter.Key<T>key(@NonNull String key, @NonNull Class<T> type)Creates aParameter.Keyfor storing values against.static <T> Parameter.Value.Builder<T>literal(@NonNull Class<T> returnType, @NonNull T returnedValue, @NonNull Supplier<? extends Collection<String>> literalSupplier)Creates a builder that has aValueParameterthat requires an argument to be a literal specifiedstatic <T> Parameter.Value.Builder<T>literal(@NonNull Class<T> returnType, @NonNull T returnedValue, String @NonNull ... literal)Creates a builder that has aValueParameterthat requires an argument to be a literal specifiedstatic Parameter.Value.Builder<ServerLocation>location()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LOCATION.static Parameter.Value.Builder<Long>longNumber()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LONG.static Parameter.Value.Builder<Operator>operator()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.OPERATOR.static Parameter.Value.Builder<ServerPlayer>player()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLAYER.static Parameter.Value.Builder<ServerPlayer>playerOrTarget()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLAYER, else the targetstatic Parameter.Value.Builder<org.spongepowered.plugin.PluginContainer>plugin()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLUGIN.static Parameter.Value.Builder<Double>rangedDouble(double min, double max)Creates a builder that has theValueParameterset toVariableValueParameters.doubleRange(), using the specified bounds (inclusive).static Parameter.Value.Builder<Integer>rangedInteger(int min, int max)Creates a builder that has theValueParameterset toVariableValueParameters.integerRange(), using the specified bounds (inclusive).static <T> Parameter.Value.Builder<T>registryElement(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull List<Function<CommandContext,@Nullable RegistryHolder>> holderProviders, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces)Creates a builder that has theValueParameterthat allows you to choose from cataloged types.static <T> Parameter.Value.Builder<T>registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull Function<CommandContext,@Nullable RegistryHolder> holderProvider, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces)Creates a builder that has theValueParameterthat 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 String @NonNull ... defaultNamespaces)Creates a builder that has theValueParameterthat allows you to choose from types registered in a givenRegistry.static Parameter.Value.Builder<String>remainingJoinedStrings()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS.static Parameter.Value.Builder<ResourceKey>resourceKey()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.RESOURCE_KEY.static Parameter.Value.Builder<Vector3d>rotation()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ROTATION.static Parameterseq(@NonNull Iterable<Parameter> parameters)Returns aParameterthat parses arguments using the supplied parameters in order.static Parameterseq(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters)Returns aParameterthat parses arguments using the supplied parameters in order.static Parameter.SequenceBuilderseqBuilder(@NonNull Parameter parameter)Returns aParameter.SequenceBuilderthat parses arguments using the supplied parameters in order.static Parameter.Value.Builder<String>string()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.STRING.static Parameter.Subcommandsubcommand(@NonNull Command.Parameterized subcommand, @NonNull String alias, String @NonNull ... aliases)Gets aParameterthat represents a subcommand.static Parameter.Value.Builder<URL>url()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.URL.static Parameter.Value.Builder<UUID>user()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.USER.static Parameter.Value.Builder<UUID>uuid()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.UUID.static Parameter.Value.Builder<Vector3d>vector3d()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.VECTOR3D.static Parameter.Value.Builder<ServerWorld>world()Creates a builder that has theValueParameterset toResourceKeyedValueParameters.WORLD.
-
-
-
Method Detail
-
key
static <T> Parameter.Key<T> key(@NonNull String key, @NonNull io.leangen.geantyref.TypeToken<T> typeToken)
Creates aParameter.Keyfor 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 String key, @NonNull Class<T> type)
Creates aParameter.Keyfor 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 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 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 aClassparameter- 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 aTypeTokenparameter- The value parameter- Returns:
- The
Parameter.Value.Builder
-
builder
static <T,V extends ValueParameter<T>> Parameter.Value.Builder<T> builder(@NonNull Class<T> valueClass, @NonNull DefaultedRegistryReference<V> parameter)
Gets a builder that builds aParameter.Value.- Type Parameters:
T- The type of parameterV- TheValueParameterto 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 Supplier<V> parameter)
Gets a builder that builds aParameter.Value.- Type Parameters:
T- The type of parameterV- TheValueParameterto 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 String alias, String @NonNull ... aliases)
Gets aParameterthat represents a subcommand.If a
Parameter.Subcommandalias 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- TheCommandto executealias- The first alias of the subcommandaliases- Subsequent aliases, if any- Returns:
- The
Parameter.Subcommandfor use in aParameterchain
-
firstOfBuilder
static Parameter.FirstOfBuilder firstOfBuilder(@NonNull Parameter parameter)
Returns aParameter.FirstOfBuilderthat 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.FirstOfBuilderto continue chaining
-
firstOf
static Parameter firstOf(@NonNull Parameter first, @NonNull Parameter second, Parameter @NonNull ... parameters)
Returns aParameterthat 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 Iterable<Parameter> parameters)
Returns aParameterthat 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.SequenceBuilderthat parses arguments using the supplied parameters in order.- Parameters:
parameter- The firstParameterin 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 aParameterthat parses arguments using the supplied parameters in order.
-
seq
static Parameter seq(@NonNull Iterable<Parameter> parameters)
Returns aParameterthat parses arguments using the supplied parameters in order.
-
bigDecimal
static Parameter.Value.Builder<BigDecimal> bigDecimal()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_DECIMAL.- Returns:
- A
Parameter.Value.Builder
-
bigInteger
static Parameter.Value.Builder<BigInteger> bigInteger()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BIG_INTEGER.- Returns:
- A
Parameter.Value.Builder
-
blockState
static Parameter.Value.Builder<BlockState> blockState()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BLOCK_STATE.- Returns:
- A
Parameter.Value.Builder
-
bool
static Parameter.Value.Builder<Boolean> bool()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.BOOLEAN.- Returns:
- A
Parameter.Value.Builder
-
color
static Parameter.Value.Builder<Color> color()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.COLOR.- Returns:
- A
Parameter.Value.Builder
-
dataContainer
static Parameter.Value.Builder<DataContainer> dataContainer()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATA_CONTAINER.- Returns:
- A
Parameter.Value.Builder
-
dateTime
static Parameter.Value.Builder<LocalDateTime> dateTime()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DATE_TIME.- Returns:
- A
Parameter.Value.Builder
-
duration
static Parameter.Value.Builder<Duration> duration()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DURATION.- Returns:
- A
Parameter.Value.Builder
-
doubleNumber
static Parameter.Value.Builder<Double> doubleNumber()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.DOUBLE.- Returns:
- A
Parameter.Value.Builder
-
entity
static Parameter.Value.Builder<Entity> entity()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITY.- Returns:
- A
Parameter.Value.Builder
-
entityOrTarget
static Parameter.Value.Builder<Entity> entityOrTarget()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ENTITY- Returns:
- A
Parameter.Value.Builder
-
formattingCodeText
static Parameter.Value.Builder<Component> formattingCodeText()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE.- Returns:
- A
Parameter.Value.Builder
-
formattingCodeTextOfRemainingElements
static Parameter.Value.Builder<Component> formattingCodeTextOfRemainingElements()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_FORMATTING_CODE_ALL.- Returns:
- A
Parameter.Value.Builder
-
integerNumber
static Parameter.Value.Builder<Integer> integerNumber()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.INTEGER.- Returns:
- A
Parameter.Value.Builder
-
ip
static Parameter.Value.Builder<InetAddress> ip()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.IP.- Returns:
- A
Parameter.Value.Builder
-
itemStackSnapshot
static Parameter.Value.Builder<ItemStackSnapshot> itemStackSnapshot()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ITEM_STACK_SNAPSHOT.- Returns:
- A
Parameter.Value.Builder
-
jsonText
static Parameter.Value.Builder<Component> jsonText()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON.- Returns:
- A
Parameter.Value.Builder
-
jsonTextOfRemainingElements
static Parameter.Value.Builder<Component> jsonTextOfRemainingElements()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.TEXT_JSON_ALL.- Returns:
- A
Parameter.Value.Builder
-
location
static Parameter.Value.Builder<ServerLocation> location()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LOCATION.- Returns:
- A
Parameter.Value.Builder
-
longNumber
static Parameter.Value.Builder<Long> longNumber()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.LONG.- Returns:
- A
Parameter.Value.Builder
-
operator
static Parameter.Value.Builder<Operator> operator()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.OPERATOR.- Returns:
- A
Parameter.Value.Builder
-
player
static Parameter.Value.Builder<ServerPlayer> player()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.PLAYER.- Returns:
- A
Parameter.Value.Builder
-
playerOrTarget
static Parameter.Value.Builder<ServerPlayer> playerOrTarget()
Creates a builder that has theValueParameterset 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 theValueParameterset toResourceKeyedValueParameters.PLUGIN.- Returns:
- A
Parameter.Value.Builder
-
rangedDouble
static Parameter.Value.Builder<Double> rangedDouble(double min, double max)
Creates a builder that has theValueParameterset 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<Integer> rangedInteger(int min, int max)
Creates a builder that has theValueParameterset 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<String> remainingJoinedStrings()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.REMAINING_JOINED_STRINGS.- Returns:
- A
Parameter.Value.Builder
-
resourceKey
static Parameter.Value.Builder<ResourceKey> resourceKey()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.RESOURCE_KEY.- Returns:
- A
Parameter.Value.Builder
-
rotation
static Parameter.Value.Builder<Vector3d> rotation()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.ROTATION.- Returns:
- A
Parameter.Value.Builder
-
string
static Parameter.Value.Builder<String> string()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.STRING.- Returns:
- A
Parameter.Value.Builder
-
url
static Parameter.Value.Builder<URL> url()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.URL.- Returns:
- A
Parameter.Value.Builder
-
user
static Parameter.Value.Builder<UUID> user()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.USER.- Returns:
- A
Parameter.Value.Builder
-
uuid
static Parameter.Value.Builder<UUID> uuid()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.UUID.- Returns:
- A
Parameter.Value.Builder
-
vector3d
static Parameter.Value.Builder<Vector3d> vector3d()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.VECTOR3D.- Returns:
- A
Parameter.Value.Builder
-
world
static Parameter.Value.Builder<ServerWorld> world()
Creates a builder that has theValueParameterset toResourceKeyedValueParameters.WORLD.- Returns:
- A
Parameter.Value.Builder
-
registryElement
static <T> Parameter.Value.Builder<T> registryElement(io.leangen.geantyref.TypeToken<T> type, @NonNull Function<CommandContext,@Nullable RegistryHolder> holderProvider, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameterthat allows you to choose from cataloged types.See
#defaultNamespace(String)for how default namespaces work.If the
GameorServerscopedRegistryHolderis required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDERorVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDERmay be used.- Type Parameters:
T- The type of registry value- Parameters:
type- The registry value type to check for choicesholderProvider- AFunctionthat provides the appropriateRegistryHolderto get the appropriateRegistryregistryKey- TheRegistryKeythat represents the targetRegistrydefaultNamespaces- 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 List<Function<CommandContext,@Nullable RegistryHolder>> holderProviders, @NonNull RegistryType<T> registryKey, @NonNull String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameterthat allows you to choose from cataloged types.See
#defaultNamespace(String)for how default namespaces work.If the
GameorServerscopedRegistryHolderis required,VariableValueParameters.RegistryEntryBuilder.GLOBAL_HOLDER_PROVIDERorVariableValueParameters.RegistryEntryBuilder.SERVER_HOLDER_PROVIDERmay be used.- Type Parameters:
T- The type of registry value- Parameters:
type- The registry value type to check for choicesholderProviders-Functions that provides the appropriateRegistryHolderto get the appropriateRegistryregistryKey- TheRegistryKeythat represents the targetRegistrydefaultNamespaces- 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 String @NonNull ... defaultNamespaces)
Creates a builder that has theValueParameterthat 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- TheDefaultedRegistryTypeto 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<String> choices(String @NonNull ... choices)
Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen fromThis will return a parser that will return
Strings- Parameters:
choices- The choices- Returns:
- A
Parameter.Value.Builder
-
choices
static <T> Parameter.Value.Builder<T> choices(@NonNull Class<T> returnType, @NonNull Map<String,? extends T> choices)
Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContextwhen 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 Class<T> returnType, @NonNull Function<String,? extends T> valueFunction, @NonNull Supplier<? extends Collection<String>> choices)
Creates a builder that has aValueParameterthat allows you to specify a set of choices that must be chosen from. These choices map to objects that will get put in theCommandContextwhen 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 theCommandContextbased on the supplied choicechoices- The choices- Returns:
- A
Parameter.Value.Builder
-
enumValue
static <T extends Enum<T>> Parameter.Value.Builder<T> enumValue(@NonNull Class<T> enumClass)
Creates a builder that has aValueParameterthat requires an argument that matches the name of a suppliedEnumtype- Type Parameters:
T- The type ofEnum- Parameters:
enumClass- TheEnumclass type- Returns:
- A
Parameter.Value.Builder
-
literal
static <T> Parameter.Value.Builder<T> literal(@NonNull Class<T> returnType, @NonNull T returnedValue, String @NonNull ... literal)
Creates a builder that has aValueParameterthat 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 theCommandContextif the literal matches.literal- The literal to match- Returns:
- A
Parameter.Value.Builder
-
literal
static <T> Parameter.Value.Builder<T> literal(@NonNull Class<T> returnType, @NonNull T returnedValue, @NonNull Supplier<? extends Collection<String>> literalSupplier)
Creates a builder that has aValueParameterthat requires an argument to be a literal specified- Type Parameters:
T- The type of parameter- Parameters:
returnedValue- The object to put in theCommandContextif 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
CommandExecutorif 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.
-
-