Class Command.Builder<C>
- java.lang.Object
-
- cloud.commandframework.Command.Builder<C>
-
-
Method Summary
Modifier and Type Method Description <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 Description description)
Add a new command argument to the command<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 Description description)
Add a new command argument to the command<T> @NonNull Command.Builder<C>
argument(@NonNull java.lang.Class<T> clazz, @NonNull java.lang.String name, @NonNull java.util.function.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 java.lang.String name, @NonNull Pair<@NonNull java.lang.String,@NonNull java.lang.String> names, @NonNull Pair<@NonNull java.lang.Class<U>,@NonNull java.lang.Class<V>> parserPair, @NonNull Description description)
Create a new argument pair that maps toPair
<U,V,O>
@NonNull Command.Builder<C>argumentPair(@NonNull java.lang.String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Pair<java.lang.String,java.lang.String> names, @NonNull Pair<java.lang.Class<U>,java.lang.Class<V>> parserPair, @NonNull java.util.function.BiFunction<C,Pair<U,V>,O> mapper, @NonNull Description description)
Create a new argument pair that maps to a custom type.<U,V,W>
@NonNull Command.Builder<C>argumentTriplet(@NonNull java.lang.String name, @NonNull Triplet<java.lang.String,java.lang.String,java.lang.String> names, @NonNull Triplet<java.lang.Class<U>,java.lang.Class<V>,java.lang.Class<W>> parserTriplet, @NonNull Description description)
Create a new argument pair that maps toTriplet
<U,V,W,O>
@NonNull Command.Builder<C>argumentTriplet(@NonNull java.lang.String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Triplet<java.lang.String,java.lang.String,java.lang.String> names, @NonNull Triplet<java.lang.Class<U>,java.lang.Class<V>,java.lang.Class<W>> parserTriplet, @NonNull java.util.function.BiFunction<C,Triplet<U,V,W>,O> mapper, @NonNull Description description)
Create a new argument triplet that maps to a custom type.@NonNull Command<C>
build()
Build a command using the builder instance<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 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 java.lang.String main, @NonNull Description description, @NonNull java.lang.String... aliases)
Inserts a requiredStaticArgument
into the command chain@NonNull Command.Builder<C>
literal(@NonNull java.lang.String main, @NonNull java.lang.String... aliases)
Inserts a requiredStaticArgument
into the command chain@NonNull Command.Builder<C>
manager(@Nullable CommandManager<C> commandManager)
Supply a command manager instance to the builder.@NonNull Command.Builder<C>
meta(@NonNull java.lang.String key, @NonNull java.lang.String value)
Add command meta to the internal command meta map@NonNull Command.Builder<C>
permission(@NonNull CommandPermission permission)
Specify a command permission@NonNull Command.Builder<C>
permission(@NonNull java.lang.String permission)
Specify a command permission@NonNull Command.Builder<C>
proxies(@NonNull Command<C> command)
Make the current command be a proxy of the supplied command.@NonNull Command.Builder<C>
senderType(@NonNull java.lang.Class<? extends C> senderType)
Specify a required sender type
-
-
-
Method Detail
-
meta
public @NonNull Command.Builder<C> meta(@NonNull java.lang.String key, @NonNull java.lang.String value)
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
-
manager
public @NonNull Command.Builder<C> manager(@Nullable CommandManager<C> commandManager)
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
public @NonNull Command.Builder<C> literal(@NonNull java.lang.String main, @NonNull java.lang.String... aliases)
Inserts a requiredStaticArgument
into the command chain- Parameters:
main
- Main argument namealiases
- Argument aliases- Returns:
- New builder instance with the modified command chain
-
literal
public @NonNull Command.Builder<C> literal(@NonNull java.lang.String main, @NonNull Description description, @NonNull java.lang.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
-
argument
public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument.Builder<C,T> builder)
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
public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument<C,T> 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
public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument<C,T> argument, @NonNull Description 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
-
argument
public <T> @NonNull Command.Builder<C> argument(@NonNull CommandArgument.Builder<C,T> builder, @NonNull Description 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
-
argument
public <T> @NonNull Command.Builder<C> argument(@NonNull java.lang.Class<T> clazz, @NonNull java.lang.String name, @NonNull java.util.function.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
public <U,V> @NonNull Command.Builder<C> argumentPair(@NonNull java.lang.String name, @NonNull Pair<@NonNull java.lang.String,@NonNull java.lang.String> names, @NonNull Pair<@NonNull java.lang.Class<U>,@NonNull java.lang.Class<V>> parserPair, @NonNull Description 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
-
argumentPair
public <U,V,O> @NonNull Command.Builder<C> argumentPair(@NonNull java.lang.String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Pair<java.lang.String,java.lang.String> names, @NonNull Pair<java.lang.Class<U>,java.lang.Class<V>> parserPair, @NonNull java.util.function.BiFunction<C,Pair<U,V>,O> mapper, @NonNull Description 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
-
argumentTriplet
public <U,V,W> @NonNull Command.Builder<C> argumentTriplet(@NonNull java.lang.String name, @NonNull Triplet<java.lang.String,java.lang.String,java.lang.String> names, @NonNull Triplet<java.lang.Class<U>,java.lang.Class<V>,java.lang.Class<W>> parserTriplet, @NonNull Description 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
-
argumentTriplet
public <U,V,W,O> @NonNull Command.Builder<C> argumentTriplet(@NonNull java.lang.String name, @NonNull io.leangen.geantyref.TypeToken<O> outputType, @NonNull Triplet<java.lang.String,java.lang.String,java.lang.String> names, @NonNull Triplet<java.lang.Class<U>,java.lang.Class<V>,java.lang.Class<W>> parserTriplet, @NonNull java.util.function.BiFunction<C,Triplet<U,V,W>,O> mapper, @NonNull Description 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
-
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
-
senderType
public @NonNull Command.Builder<C> senderType(@NonNull java.lang.Class<? extends C> senderType)
Specify a required sender type- Parameters:
senderType
- Required sender type- Returns:
- New builder instance using the command execution handler
-
permission
public @NonNull Command.Builder<C> permission(@NonNull CommandPermission permission)
Specify a command permission- Parameters:
permission
- Command permission- Returns:
- New builder instance using the command permission
-
permission
public @NonNull Command.Builder<C> permission(@NonNull java.lang.String permission)
Specify a command permission- Parameters:
permission
- Command permission- Returns:
- New builder instance using the command permission
-
proxies
public @NonNull Command.Builder<C> proxies(@NonNull Command<C> command)
Make the current command be a proxy of the supplied command. This means that all of the proxied commands variable command arguments will be inserted into this builder instance, in the order they are declared in the proxied command. Furthermore, the proxied commands command handler will be showed 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
-
hidden
public @NonNull Command.Builder<C> hidden()
Indicate that the command should be hidden from help menus and other places where commands are exposed to users- Returns:
- New builder instance that indicates that the constructed command should be hidden
-
flag
public <T> @NonNull Command.Builder<C> flag(@NonNull CommandFlag<T> 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
public <T> @NonNull Command.Builder<C> flag(@NonNull CommandFlag.Builder<T> builder)
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
-
-