Package dev.jorel.commandapi.arguments
Class CustomArgument<T,B>
java.lang.Object
dev.jorel.commandapi.ArgumentTree
dev.jorel.commandapi.arguments.Argument<T>
dev.jorel.commandapi.arguments.CustomArgument<T,B>
- Type Parameters:
T- the return type of this custom argument when it is usedB- the return type of the underlying base argumentbase. For example, this would beIntegerfor anIntegerArgument
An argument that represents any custom object
- API Note:
- Returns a
CustomArgumentobject
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn exception used to create command-related errors for the CustomArgumentstatic final recordA record which contains information which can be passed to the custom argument's parser.static interfaceA FunctionalInterface that takes in aCustomArgument.CustomArgumentInfo, returns T and can throw aCustomArgument.CustomArgumentExceptionstatic classMessageBuilder is used to create error messages for invalid argument inputs -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CustomCommandExecutor<?>The CustomCommandExecutor for this executable implementation -
Constructor Summary
ConstructorsConstructorDescriptionCustomArgument(Argument<B> base, CustomArgument.CustomArgumentInfoParser<T, B> parser) Creates a CustomArgument with a valid parser, with an underlying base argument as its parsing implementation.CustomArgument(String nodeName, CustomArgument.CustomArgumentInfoParser<T, String> parser) Deprecated, for removal: This API element is subject to removal in a future version.CustomArgument(String nodeName, CustomArgument.CustomArgumentInfoParser<T, String> parser, boolean keyed) Deprecated, for removal: This API element is subject to removal in a future version.UseCustomArgument(Argument, CustomArgumentInfoParser)withTextArgumentorNamespacedKeyArgumentinstead -
Method Summary
Modifier and TypeMethodDescriptionClear all executors from the current command builderexecutes(CommandExecutor executor, ExecutorType... types) Adds an executor to the current command builderexecutes(ResultingCommandExecutor executor, ExecutorType... types) Adds an executor to the current command builderAdds an executor to the current command builderAdds an executor to the current command builderexecutesConsole(ConsoleCommandExecutor executor) Adds an executor to the current command builderAdds an executor to the current command builderexecutesEntity(EntityCommandExecutor executor) Adds an executor to the current command builderexecutesEntity(EntityResultingCommandExecutor executor) Adds an executor to the current command builderexecutesNative(NativeCommandExecutor executor) Adds an executor to the current command builderexecutesNative(NativeResultingCommandExecutor executor) Adds an executor to the current command builderexecutesPlayer(PlayerCommandExecutor executor) Adds an executor to the current command builderexecutesPlayer(PlayerResultingCommandExecutor executor) Adds an executor to the current command builderexecutesProxy(ProxyCommandExecutor executor) Adds an executor to the current command builderexecutesProxy(ProxyResultingCommandExecutor executor) Adds an executor to the current command builderReturns the argument type for this argument.CustomCommandExecutor<? extends org.bukkit.command.CommandSender>Returns the executors that this command hasReturns the primitive type of the current Argument.<CommandListenerWrapper>
TparseArgument(NMS<CommandListenerWrapper> nms, com.mojang.brigadier.context.CommandContext<CommandListenerWrapper> cmdCtx, String key, Object[] previousArgs) Parses an argument, returning the specific Bukkit object that the argument represents.voidsetExecutor(CustomCommandExecutor<? extends org.bukkit.command.CommandSender> executor) Sets the executors for this commandMethods inherited from class dev.jorel.commandapi.arguments.Argument
getArgumentPermission, getEntityNames, getIncludedSuggestions, getNodeName, getOverriddenSuggestions, getRawType, getRequirements, includeSuggestions, includeSuggestions, includeSuggestionsT, isListed, replaceSuggestions, replaceSuggestions, replaceSuggestionsT, setListed, withPermission, withPermission, withRequirementMethods inherited from class dev.jorel.commandapi.ArgumentTree
then
-
Field Details
-
executor
The CustomCommandExecutor for this executable implementation
-
-
Constructor Details
-
CustomArgument
@Deprecated(forRemoval=true) public CustomArgument(String nodeName, CustomArgument.CustomArgumentInfoParser<T, String> parser) Deprecated, for removal: This API element is subject to removal in a future version.UseCustomArgument(Argument, CustomArgumentInfoParser)withTextArgumentinsteadCreates a CustomArgument with a valid parser, defaults to non-keyed argument- Parameters:
nodeName- the name of the node for this argumentparser- ACustomArgument.CustomArgumentInfoparser object which includes information such as the command sender, previously declared arguments and current input. This parser should return an object of your choice.
-
CustomArgument
@Deprecated(forRemoval=true) public CustomArgument(String nodeName, CustomArgument.CustomArgumentInfoParser<T, String> parser, boolean keyed) Deprecated, for removal: This API element is subject to removal in a future version.UseCustomArgument(Argument, CustomArgumentInfoParser)withTextArgumentorNamespacedKeyArgumentinsteadCreates a CustomArgument with a valid parser, defaults to non-keyed argument- Parameters:
nodeName- the name of the node for this argumentparser- ACustomArgument.CustomArgumentInfoparser object which includes information such as the command sender, previously declared arguments and current input. This parser should return an object of your choice.keyed- Whether this argument can accept Minecraft'sNamespacedKeyas valid arguments
-
CustomArgument
Creates a CustomArgument with a valid parser, with an underlying base argument as its parsing implementation.- Parameters:
base- the base argument to use for this custom argument. This base argument will represent the parsing implementation for client side and server side parsing. This base argument cannot be aLiteralArgumentorMultiLiteralArgumentparser- ACustomArgument.CustomArgumentInfoparser object which includes information such as the command sender, previously declared arguments and current input. This parser should return an object of your choice.<T>the return type of this custom argument when it is used
<B>the return type of the underlying base argumentbase. For example, this would beIntegerfor anIntegerArgument
-
-
Method Details
-
getPrimitiveType
Description copied from class:ArgumentReturns the primitive type of the current Argument. After executing a command, this argument should yield an object of this returned class.- Specified by:
getPrimitiveTypein classArgument<T>- Returns:
- the type that this argument yields when the command is run
-
getArgumentType
Description copied from class:ArgumentReturns the argument type for this argument.- Specified by:
getArgumentTypein classArgument<T>- Returns:
- the argument type for this argument
-
parseArgument
public <CommandListenerWrapper> T parseArgument(NMS<CommandListenerWrapper> nms, com.mojang.brigadier.context.CommandContext<CommandListenerWrapper> cmdCtx, String key, Object[] previousArgs) throws com.mojang.brigadier.exceptions.CommandSyntaxException Description copied from class:ArgumentParses an argument, returning the specific Bukkit object that the argument represents. This is intended for use by the internals of the CommandAPI and isn't expected to be used outside the CommandAPI- Specified by:
parseArgumentin classArgument<T>- Type Parameters:
CommandListenerWrapper- the command source type- Parameters:
nms- an instance of NMScmdCtx- the context which ran this commandkey- the name of the argument nodepreviousArgs- an array of previously declared arguments- Returns:
- the parsed object represented by this argument
- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException- if parsing fails
-
executes
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(CommandSender, Object[]) -> ()that will be executed when the command is runtypes- A list of executor types to use this executes method for.- Returns:
- this command builder
-
executes
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(CommandSender, Object[]) -> intthat will be executed when the command is runtypes- A list of executor types to use this executes method for.- Returns:
- this command builder
-
executesPlayer
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Player, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesPlayer
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Player, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesEntity
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesEntity
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesProxy
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesProxy
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(Entity, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesCommandBlock
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesCommandBlock
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesConsole
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesConsole
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(BlockCommandSender, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
executesNative
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(NativeCommandExecutor, Object[]) -> ()that will be executed when the command is run- Returns:
- this command builder
-
executesNative
Adds an executor to the current command builder- Parameters:
executor- A lambda of type(NativeCommandExecutor, Object[]) -> intthat will be executed when the command is run- Returns:
- this command builder
-
getExecutor
Returns the executors that this command has- Returns:
- the executors that this command has
-
setExecutor
Sets the executors for this command- Parameters:
executor- the executors for this command
-
clearExecutors
Clear all executors from the current command builder- Returns:
- this command builder
-
CustomArgument(Argument, CustomArgumentInfoParser)withTextArgumentinstead