Class ChatArgument

java.lang.Object
dev.jorel.commandapi.ArgumentTree
dev.jorel.commandapi.arguments.Argument<net.md_5.bungee.api.chat.BaseComponent[]>
dev.jorel.commandapi.arguments.ChatArgument
All Implemented Interfaces:
IGreedyArgument, IPreviewable<ChatArgument,net.md_5.bungee.api.chat.BaseComponent[]>

public class ChatArgument extends Argument<net.md_5.bungee.api.chat.BaseComponent[]> implements IGreedyArgument, IPreviewable<ChatArgument,net.md_5.bungee.api.chat.BaseComponent[]>
An argument that represents chat with entity selectors
API Note:
Returns a BaseComponent[] object
  • Field Details

    • executor

      protected CustomCommandExecutor<?> executor
      The CustomCommandExecutor for this executable implementation
  • Constructor Details

    • ChatArgument

      public ChatArgument(String nodeName)
      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

      public Class<net.md_5.bungee.api.chat.BaseComponent[]> getPrimitiveType()
      Description copied from class: Argument
      Returns the primitive type of the current Argument. After executing a command, this argument should yield an object of this returned class.
      Specified by:
      getPrimitiveType in class Argument<net.md_5.bungee.api.chat.BaseComponent[]>
      Returns:
      the type that this argument yields when the command is run
    • getArgumentType

      public CommandAPIArgumentType getArgumentType()
      Description copied from class: Argument
      Returns the argument type for this argument.
      Specified by:
      getArgumentType in class Argument<net.md_5.bungee.api.chat.BaseComponent[]>
      Returns:
      the argument type for this argument
    • parseArgument

      public <CommandListenerWrapper> net.md_5.bungee.api.chat.BaseComponent[] 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: Argument
      Parses 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:
      parseArgument in class Argument<net.md_5.bungee.api.chat.BaseComponent[]>
      Type Parameters:
      CommandListenerWrapper - the command source type
      Parameters:
      nms - an instance of NMS
      cmdCtx - the context which ran this command
      key - the name of the argument node
      previousArgs - 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 ChatArgument withPreview(PreviewableFunction<net.md_5.bungee.api.chat.BaseComponent[]> preview)
      Description copied from interface: IPreviewable
      Sets the PreviewableFunction for this argument. This function will run when a player requests a chat preview from the server. The function's PreviewInfo will be populated based on the input for the relevant player that requests the chat preview.
      Specified by:
      withPreview in interface IPreviewable<ChatArgument,net.md_5.bungee.api.chat.BaseComponent[]>
      Parameters:
      preview - the function to use for chat preview generation
      Returns:
      the current argument
    • getPreview

      public Optional<PreviewableFunction<net.md_5.bungee.api.chat.BaseComponent[]>> getPreview()
      Specified by:
      getPreview in interface IPreviewable<ChatArgument,net.md_5.bungee.api.chat.BaseComponent[]>
      Returns:
      the PreviewableFunction for this argument, as an Optional.
    • isLegacy

      public boolean isLegacy()
      Specified by:
      isLegacy in interface IPreviewable<ChatArgument,net.md_5.bungee.api.chat.BaseComponent[]>
      Returns:
      whether this argument uses legacy chat component APIs
    • usePreview

      public ChatArgument usePreview(boolean usePreview)
      Description copied from interface: IPreviewable
      Whether this argument should use the preview result as the argument value for execution. If set to true, accessing this argument in args will return the same value generated from IPreviewable.withPreview(PreviewableFunction)
      Specified by:
      usePreview in interface IPreviewable<ChatArgument,net.md_5.bungee.api.chat.BaseComponent[]>
      Parameters:
      usePreview - whether to use the preview as the value for this argument
      Returns:
      the current argument
    • executes

      public ArgumentTree executes(CommandExecutor executor, ExecutorType... types)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (CommandSender, Object[]) -> () that will be executed when the command is run
      types - A list of executor types to use this executes method for.
      Returns:
      this command builder
    • executes

      public ArgumentTree executes(ResultingCommandExecutor executor, ExecutorType... types)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (CommandSender, Object[]) -> int that will be executed when the command is run
      types - A list of executor types to use this executes method for.
      Returns:
      this command builder
    • executesPlayer

      public ArgumentTree executesPlayer(PlayerCommandExecutor executor)
      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

      public ArgumentTree executesPlayer(PlayerResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Player, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesEntity

      public ArgumentTree executesEntity(EntityCommandExecutor executor)
      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

      public ArgumentTree executesEntity(EntityResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesProxy

      public ArgumentTree executesProxy(ProxyCommandExecutor executor)
      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

      public ArgumentTree executesProxy(ProxyResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (Entity, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesCommandBlock

      public ArgumentTree executesCommandBlock(CommandBlockCommandExecutor executor)
      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

      public ArgumentTree executesCommandBlock(CommandBlockResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesConsole

      public ArgumentTree executesConsole(ConsoleCommandExecutor executor)
      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

      public ArgumentTree executesConsole(ConsoleResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (BlockCommandSender, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • executesNative

      public ArgumentTree executesNative(NativeCommandExecutor executor)
      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

      public ArgumentTree executesNative(NativeResultingCommandExecutor executor)
      Adds an executor to the current command builder
      Parameters:
      executor - A lambda of type (NativeCommandExecutor, Object[]) -> int that will be executed when the command is run
      Returns:
      this command builder
    • getExecutor

      public CustomCommandExecutor<? extends org.bukkit.command.CommandSender> getExecutor()
      Returns the executors that this command has
      Returns:
      the executors that this command has
    • setExecutor

      public void setExecutor(CustomCommandExecutor<? extends org.bukkit.command.CommandSender> executor)
      Sets the executors for this command
      Parameters:
      executor - the executors for this command
    • clearExecutors

      public ArgumentTree clearExecutors()
      Clear all executors from the current command builder
      Returns:
      this command builder