Package dev.jorel.commandapi.arguments
Class AdventureChatArgument
java.lang.Object
dev.jorel.commandapi.ArgumentTree
dev.jorel.commandapi.arguments.Argument<net.kyori.adventure.text.Component>
dev.jorel.commandapi.arguments.AdventureChatArgument
- All Implemented Interfaces:
IGreedyArgument,IPreviewable<AdventureChatArgument,net.kyori.adventure.text.Component>
public class AdventureChatArgument
extends Argument<net.kyori.adventure.text.Component>
implements IGreedyArgument, IPreviewable<AdventureChatArgument,net.kyori.adventure.text.Component>
An argument that represents chat with entity selectors
- API Note:
- Returns a
Componentobject
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CustomCommandExecutor<?>The CustomCommandExecutor for this executable implementation -
Constructor Summary
ConstructorsConstructorDescriptionAdventureChatArgument(String nodeName) Constructs a Chat argument with a given node name. -
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 hasOptional<PreviewableFunction<net.kyori.adventure.text.Component>>Class<net.kyori.adventure.text.Component>Returns the primitive type of the current Argument.booleanisLegacy()<CommandListenerWrapper>
net.kyori.adventure.text.ComponentparseArgument(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 commandusePreview(boolean usePreview) Whether this argument should use the preview result as the argument value for execution.withPreview(PreviewableFunction<net.kyori.adventure.text.Component> preview) Sets thePreviewableFunctionfor this argument.Methods 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
-
AdventureChatArgument
Constructs a Chat argument with a given node name. Represents fancy greedy strings that can parse entity selectors- Parameters:
nodeName- the name of the node for argument
-
-
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<net.kyori.adventure.text.Component>- 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<net.kyori.adventure.text.Component>- Returns:
- the argument type for this argument
-
parseArgument
public <CommandListenerWrapper> net.kyori.adventure.text.Component 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<net.kyori.adventure.text.Component>- 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
-
withPreview
public AdventureChatArgument withPreview(PreviewableFunction<net.kyori.adventure.text.Component> preview) Description copied from interface:IPreviewableSets thePreviewableFunctionfor this argument. This function will run when a player requests a chat preview from the server. The function'sPreviewInfowill be populated based on the input for the relevant player that requests the chat preview.- Specified by:
withPreviewin interfaceIPreviewable<AdventureChatArgument,net.kyori.adventure.text.Component> - Parameters:
preview- the function to use for chat preview generation- Returns:
- the current argument
-
getPreview
- Specified by:
getPreviewin interfaceIPreviewable<AdventureChatArgument,net.kyori.adventure.text.Component> - Returns:
- the
PreviewableFunctionfor this argument, as anOptional.
-
isLegacy
public boolean isLegacy()- Specified by:
isLegacyin interfaceIPreviewable<AdventureChatArgument,net.kyori.adventure.text.Component> - Returns:
- whether this argument uses legacy chat component APIs
-
usePreview
Description copied from interface:IPreviewableWhether this argument should use the preview result as the argument value for execution. If set to true, accessing this argument inargswill return the same value generated fromIPreviewable.withPreview(PreviewableFunction)- Specified by:
usePreviewin interfaceIPreviewable<AdventureChatArgument,net.kyori.adventure.text.Component> - Parameters:
usePreview- whether to use the preview as the value for this argument- Returns:
- the current argument
-
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
-