Class Command.Builder<C>
- Type Parameters:
C
- Command sender type
Command
instances. The builder is immutable, and each
setter method will return a new builder instance.-
Method Summary
Modifier and TypeMethodDescription<T> @NonNull Command.Builder<C>
argument
(@NonNull CommandArgument.Builder<C, T> builder) Add a new command argument with an empty description to the command<T> @NonNull Command.Builder<C>
argument
(@NonNull CommandArgument.Builder<C, T> builder, @NonNull ArgumentDescription description) Add a new command argument to the command<T> @NonNull Command.Builder<C>
argument
(@NonNull CommandArgument.Builder<C, T> builder, @NonNull Description description) Deprecated.for removal since 1.4.0.<T> @NonNull Command.Builder<C>
argument
(@NonNull CommandArgument<C, T> argument) Add a new command argument with an empty description to the command<T> @NonNull Command.Builder<C>
argument
(@NonNull CommandArgument<C, T> argument, @NonNull ArgumentDescription description) Add a new command argument to the command<T> @NonNull Command.Builder<C>
argument
(@NonNull CommandArgument<C, T> argument, @NonNull Description description) Deprecated.for removal since 1.4.0.<T> @NonNull Command.Builder<C>
argument
(@NonNull Class<T> clazz, @NonNull String name, @NonNull Consumer<CommandArgument.Builder<C, T>> builderConsumer) Add a new command argument by interacting with a constructed command argument builder<U,
V> @NonNull Command.Builder<C> argumentPair
(@NonNull String name, @NonNull Pair<@NonNull String, @NonNull String> names, @NonNull Pair<@NonNull Class<U>, @NonNull Class<V>> parserPair, @NonNull ArgumentDescription description) Create a new argument pair that maps toPair
<U,
V> @NonNull Command.Builder<C> argumentPair
(@NonNull String name, @NonNull Pair<@NonNull String, @NonNull String> names, @NonNull Pair<@NonNull Class<U>, @NonNull Class<V>> parserPair, @NonNull Description description) Deprecated.for removal since 1.4.0.<U,
V, O> @NonNull Command.Builder<C> argumentPair
(@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Pair<String, String> names, @NonNull Pair<Class<U>, Class<V>> parserPair, @NonNull BiFunction<C, Pair<U, V>, O> mapper, @NonNull ArgumentDescription description) Create a new argument pair that maps to a custom type.<U,
V, O> @NonNull Command.Builder<C> argumentPair
(@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Pair<String, String> names, @NonNull Pair<Class<U>, Class<V>> parserPair, @NonNull BiFunction<C, Pair<U, V>, O> mapper, @NonNull Description description) Deprecated.for removal since 1.4.0.<U,
V, W> @NonNull Command.Builder<C> argumentTriplet
(@NonNull String name, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull ArgumentDescription description) Create a new argument pair that maps toTriplet
<U,
V, W> @NonNull Command.Builder<C> argumentTriplet
(@NonNull String name, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull Description description) Deprecated.for removal since 1.4.0.<U,
V, W, O> @NonNull Command.Builder<C> argumentTriplet
(@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull BiFunction<C, Triplet<U, V, W>, O> mapper, @NonNull ArgumentDescription description) Create a new argument triplet that maps to a custom type.<U,
V, W, O> @NonNull Command.Builder<C> argumentTriplet
(@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull BiFunction<C, Triplet<U, V, W>, O> mapper, @NonNull Description description) Deprecated.for removal since 1.4.0, useargumentTriplet(String, TypeToken, Triplet, Triplet, BiFunction, ArgumentDescription)
instead.build()
Build a command using the builder instance@NonNull CommandPermission
Get the required command permission for this builder<T> @NonNull Command.Builder<C>
flag
(@NonNull CommandFlag.Builder<T> builder) Register a new command flag<T> @NonNull Command.Builder<C>
flag
(@NonNull CommandFlag<T> flag) Register a new command flag@NonNull CommandExecutionHandler<C>
handler()
Returns the current command execution handler.@NonNull Command.Builder<C>
handler
(@NonNull CommandExecutionHandler<C> commandExecutionHandler) Specify the command execution handler@NonNull Command.Builder<C>
hidden()
Indicate that the command should be hidden from help menus and other places where commands are exposed to users@NonNull Command.Builder<C>
literal
(@NonNull String main, @NonNull ArgumentDescription description, @NonNull String... aliases) Inserts a requiredStaticArgument
into the command chain@NonNull Command.Builder<C>
literal
(@NonNull String main, @NonNull Description description, @NonNull String... aliases) Deprecated.for removal since 1.4.0.@NonNull Command.Builder<C>
Inserts a requiredStaticArgument
into the command chain@NonNull Command.Builder<C>
manager
(@Nullable CommandManager<C> commandManager) Supply a command manager instance to the builder.<V> @NonNull Command.Builder<C>
meta
(@NonNull CommandMeta.Key<V> key, @NonNull V value) Add command meta to the internal command meta map@NonNull Command.Builder<C>
Deprecated.for removal since 1.2.0, use the typesafe variant atmeta(CommandMeta.Key, Object)
instead.@NonNull Command.Builder<C>
permission
(@NonNull CommandPermission permission) Specify a command permission@NonNull Command.Builder<C>
permission
(@NonNull PredicatePermission<C> permission) Specify a command permission@NonNull Command.Builder<C>
permission
(@NonNull String permission) Specify a command permission@NonNull Command.Builder<C>
Make the current command be a proxy of the supplied command.Get the required sender type for this builder@NonNull Command.Builder<C>
senderType
(@NonNull Class<? extends C> senderType) Specify a required sender type
-
Method Details
-
senderType
Get the required sender type for this builderReturns
null
when there is not a specific required sender type- Returns:
- required sender type
- Since:
- 1.3.0
-
commandPermission
Get the required command permission for this builderWill return
Permission.empty()
if there is no required permission- Returns:
- required permission
- Since:
- 1.3.0
-
meta
@Deprecated @API(status=DEPRECATED, since="1.2.0") public @NonNull Command.Builder<C> meta(@NonNull String key, @NonNull String value) Deprecated.for removal since 1.2.0, use the typesafe variant atmeta(CommandMeta.Key, Object)
instead.Add command meta to the internal command meta map- Parameters:
key
- Meta keyvalue
- Meta value- Returns:
- New builder instance using the inserted meta key-value pair
-
meta
@API(status=STABLE, since="1.3.0") public <V> @NonNull Command.Builder<C> meta(@NonNull CommandMeta.Key<V> key, @NonNull V value) Add command meta to the internal command meta map- Type Parameters:
V
- Meta value type- Parameters:
key
- Meta keyvalue
- Meta value- Returns:
- New builder instance using the inserted meta key-value pair
- Since:
- 1.3.0
-
manager
Supply a command manager instance to the builder. This will be used when attempting to retrieve command argument parsers, in the case that they're needed. This is optional- Parameters:
commandManager
- Command manager- Returns:
- New builder instance using the provided command manager
-
literal
Inserts a requiredStaticArgument
into the command chain- Parameters:
main
- Main argument namealiases
- Argument aliases- Returns:
- New builder instance with the modified command chain
-
literal
@Deprecated @API(status=DEPRECATED, since="1.4.0") public @NonNull Command.Builder<C> literal(@NonNull String main, @NonNull Description description, @NonNull String... aliases) Deprecated.for removal since 1.4.0. Useliteral(String, ArgumentDescription, String...)
instead.Inserts a requiredStaticArgument
into the command chain- Parameters:
main
- Main argument namedescription
- Literal descriptionaliases
- Argument aliases- Returns:
- New builder instance with the modified command chain
-
literal
@API(status=STABLE, since="1.4.0") public @NonNull Command.Builder<C> literal(@NonNull String main, @NonNull ArgumentDescription description, @NonNull String... aliases) Inserts a requiredStaticArgument
into the command chain- Parameters:
main
- Main argument namedescription
- Literal descriptionaliases
- Argument aliases- Returns:
- New builder instance with the modified command chain
- Since:
- 1.4.0
-
argument
Add a new command argument with an empty description to the command- Type Parameters:
T
- Argument type- Parameters:
builder
- Argument to add.CommandArgument.Builder.build()
will be invoked and the result will be registered in the command.- Returns:
- New builder instance with the command argument inserted into the argument list
-
argument
Add a new command argument with an empty description to the command- Type Parameters:
T
- Argument type- Parameters:
argument
- Argument to add- Returns:
- New builder instance with the command argument inserted into the argument list
-
argument
@Deprecated @API(status=DEPRECATED, since="1.4.0") public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument<C, T> argument, @NonNull Description description) Deprecated.for removal since 1.4.0. Useargument(CommandArgument, ArgumentDescription)
instead.Add a new command argument to the command- Type Parameters:
T
- Argument type- Parameters:
argument
- Argument to adddescription
- Argument description- Returns:
- New builder instance with the command argument inserted into the argument list
-
argument
@API(status=STABLE, since="1.4.0") public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument<C, T> argument, @NonNull ArgumentDescription description) Add a new command argument to the command- Type Parameters:
T
- Argument type- Parameters:
argument
- Argument to adddescription
- Argument description- Returns:
- New builder instance with the command argument inserted into the argument list
- Since:
- 1.4.0
-
argument
@Deprecated @API(status=DEPRECATED, since="1.4.0") public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument.Builder<C, T> builder, @NonNull Description description) Deprecated.for removal since 1.4.0. Useargument(CommandArgument.Builder, ArgumentDescription)
instead.Add a new command argument to the command- Type Parameters:
T
- Argument type- Parameters:
builder
- Argument to add.CommandArgument.Builder.build()
will be invoked and the result will be registered in the command.description
- Argument description- Returns:
- New builder instance with the command argument inserted into the argument list
-
argument
@API(status=STABLE, since="1.4.0") public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument.Builder<C, T> builder, @NonNull ArgumentDescription description) Add a new command argument to the command- Type Parameters:
T
- Argument type- Parameters:
builder
- Argument to add.CommandArgument.Builder.build()
will be invoked and the result will be registered in the command.description
- Argument description- Returns:
- New builder instance with the command argument inserted into the argument list
- Since:
- 1.4.0
-
argument
public <T> @NonNull Command.Builder<C> argument(@NonNull Class<T> clazz, @NonNull String name, @NonNull Consumer<CommandArgument.Builder<C, T>> builderConsumer) Add a new command argument by interacting with a constructed command argument builder- Type Parameters:
T
- Argument type- Parameters:
clazz
- Argument classname
- Argument namebuilderConsumer
- Builder consumer- Returns:
- New builder instance with the command argument inserted into the argument list
-
argumentPair
@Deprecated @API(status=DEPRECATED, since="1.4.0") public <U,V> @NonNull Command.Builder<C> argumentPair(@NonNull String name, @NonNull Pair<@NonNull String, @NonNull String> names, @NonNull Pair<@NonNull Class<U>, @NonNull Class<V>> parserPair, @NonNull Description description) Deprecated.for removal since 1.4.0. UseargumentPair(String, Pair, Pair, ArgumentDescription)
instead.Create a new argument pair that maps toPair
For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second type- Parameters:
name
- Name of the argumentnames
- Pair containing the names of the sub-argumentsparserPair
- Pair containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commanddescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
-
argumentPair
@API(status=STABLE, since="1.4.0") public <U,V> @NonNull Command.Builder<C> argumentPair(@NonNull String name, @NonNull Pair<@NonNull String, @NonNull String> names, @NonNull Pair<@NonNull Class<U>, @NonNull Class<V>> parserPair, @NonNull ArgumentDescription description) Create a new argument pair that maps toPair
For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second type- Parameters:
name
- Name of the argumentnames
- Pair containing the names of the sub-argumentsparserPair
- Pair containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commanddescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
- Since:
- 1.4.0
-
argumentPair
@Deprecated @API(status=DEPRECATED, since="1.4.0") public <U,V, @NonNull Command.Builder<C> argumentPairO> (@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Pair<String, String> names, @NonNull Pair<Class<U>, Class<V>> parserPair, @NonNull BiFunction<C, Pair<U, V>, O> mapper, @NonNull Description description) Deprecated.for removal since 1.4.0. UseargumentPair(String, TypeToken, Pair, Pair, BiFunction, ArgumentDescription)
instead.Create a new argument pair that maps to a custom type.For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second typeO
- Output type- Parameters:
name
- Name of the argumentoutputType
- The output typenames
- Pair containing the names of the sub-argumentsparserPair
- Pair containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commandmapper
- Mapper that maps fromPair
to the custom typedescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
-
argumentPair
@API(status=STABLE, since="1.4.0") public <U,V, @NonNull Command.Builder<C> argumentPairO> (@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Pair<String, String> names, @NonNull Pair<Class<U>, Class<V>> parserPair, @NonNull BiFunction<C, Pair<U, V>, O> mapper, @NonNull ArgumentDescription description) Create a new argument pair that maps to a custom type.For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second typeO
- Output type- Parameters:
name
- Name of the argumentoutputType
- The output typenames
- Pair containing the names of the sub-argumentsparserPair
- Pair containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commandmapper
- Mapper that maps fromPair
to the custom typedescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
- Since:
- 1.4.0
-
argumentTriplet
@Deprecated @API(status=DEPRECATED, since="1.4.0") public <U,V, @NonNull Command.Builder<C> argumentTripletW> (@NonNull String name, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull Description description) Deprecated.for removal since 1.4.0. UseargumentTriplet(String, Triplet, Triplet, ArgumentDescription)
instead.Create a new argument pair that maps toTriplet
For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second typeW
- Third type- Parameters:
name
- Name of the argumentnames
- Triplet containing the names of the sub-argumentsparserTriplet
- Triplet containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commanddescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
-
argumentTriplet
@API(status=STABLE, since="1.4.0") public <U,V, @NonNull Command.Builder<C> argumentTripletW> (@NonNull String name, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull ArgumentDescription description) Create a new argument pair that maps toTriplet
For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second typeW
- Third type- Parameters:
name
- Name of the argumentnames
- Triplet containing the names of the sub-argumentsparserTriplet
- Triplet containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commanddescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
- Since:
- 1.4.0
-
argumentTriplet
@Deprecated @API(status=DEPRECATED, since="1.4.0") public <U,V, @NonNull Command.Builder<C> argumentTripletW, O> (@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull BiFunction<C, Triplet<U, V, W>, O> mapper, @NonNull Description description) Deprecated.for removal since 1.4.0, useargumentTriplet(String, TypeToken, Triplet, Triplet, BiFunction, ArgumentDescription)
instead.Create a new argument triplet that maps to a custom type.For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second typeW
- Third typeO
- Output type- Parameters:
name
- Name of the argumentoutputType
- The output typenames
- Triplet containing the names of the sub-argumentsparserTriplet
- Triplet containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commandmapper
- Mapper that maps fromTriplet
to the custom typedescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
-
argumentTriplet
@API(status=STABLE, since="1.4.0") public <U,V, @NonNull Command.Builder<C> argumentTripletW, O> (@NonNull String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Triplet<String, String, String> names, @NonNull Triplet<Class<U>, Class<V>, Class<W>> parserTriplet, @NonNull BiFunction<C, Triplet<U, V, W>, O> mapper, @NonNull ArgumentDescription description) Create a new argument triplet that maps to a custom type.For this to work, there must be a
CommandManager
attached to the command builder. To guarantee this, it is recommended to get the command builder instance usingCommandManager.commandBuilder(String, String...)
- Type Parameters:
U
- First typeV
- Second typeW
- Third typeO
- Output type- Parameters:
name
- Name of the argumentoutputType
- The output typenames
- Triplet containing the names of the sub-argumentsparserTriplet
- Triplet containing the types of the sub-arguments. There must be parsers for these types registered in theParserRegistry
used by theCommandManager
attached to this commandmapper
- Mapper that maps fromTriplet
to the custom typedescription
- Description of the argument- Returns:
- Builder instance with the argument inserted
- Since:
- 1.4.0
-
handler
public @NonNull Command.Builder<C> handler(@NonNull CommandExecutionHandler<C> commandExecutionHandler) Specify the command execution handler- Parameters:
commandExecutionHandler
- New execution handler- Returns:
- New builder instance using the command execution handler
-
handler
Returns the current command execution handler.- Returns:
- the current handler
- Since:
- 1.7.0
-
senderType
Specify a required sender type- Parameters:
senderType
- Required sender type- Returns:
- New builder instance using the required sender type
-
permission
Specify a command permission- Parameters:
permission
- Command permission- Returns:
- New builder instance using the command permission
-
permission
Specify a command permission- Parameters:
permission
- Command permission- Returns:
- New builder instance using the command permission
-
permission
Specify a command permission- Parameters:
permission
- Command permission- Returns:
- New builder instance using the command permission
-
proxies
Make the current command be a proxy of the supplied command. This means that all of the proxied command's variable command arguments will be inserted into this builder instance, in the order they are declared in the proxied command. Furthermore, the proxied command's command handler will be shown by the command that is currently being built. If the current command builder does not have a permission node set, this too will be copied.- Parameters:
command
- Command to proxy- Returns:
- New builder that proxies the given command
-
flag
Register a new command flag- Type Parameters:
T
- Flag value type- Parameters:
flag
- Flag- Returns:
- New builder instance that uses the provided flag
-
flag
Register a new command flag- Type Parameters:
T
- Flag value type- Parameters:
builder
- Flag builder.CommandFlag.Builder.build()
will be invoked.- Returns:
- New builder instance that uses the provided flag
-
build
Build a command using the builder instance- Returns:
- Built command
-