Class CommandRegisteredEvent<S extends BukkitBrigadierCommandSource>

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.server.ServerEvent
com.destroystokyo.paper.event.brigadier.CommandRegisteredEvent<S>
All Implemented Interfaces:
org.bukkit.event.Cancellable

@Experimental public class CommandRegisteredEvent<S extends BukkitBrigadierCommandSource> extends org.bukkit.event.server.ServerEvent implements org.bukkit.event.Cancellable
Fired anytime the server synchronizes Bukkit commands to Brigadier.

Allows a plugin to control the command node structure for its commands. This is done at Plugin Enable time after commands have been registered, but may also run at a later point in the server lifetime due to plugins, a server reload, etc.

This is a draft/experimental API and is subject to change.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    CommandRegisteredEvent(String commandLabel, BukkitBrigadierCommand<S> brigadierCommand, org.bukkit.command.Command command, com.mojang.brigadier.tree.RootCommandNode<S> root, com.mojang.brigadier.tree.LiteralCommandNode<S> literal, com.mojang.brigadier.tree.ArgumentCommandNode<S,String> defaultArgs)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the BukkitBrigadierCommand for the Command being registered.
    org.bukkit.command.Command
    Gets the Command being registered.
    Gets the command label of the Command being registered.
    com.mojang.brigadier.tree.ArgumentCommandNode<S,String>
    Gets the Bukkit APIs default arguments node (greedy string), for if you wish to reuse it.
    static @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.event.HandlerList
     
    com.mojang.brigadier.tree.LiteralCommandNode<S>
    Gets the LiteralCommandNode to be registered for the Command.
    com.mojang.brigadier.tree.RootCommandNode<S>
    Gets the RootCommandNode which is being registered to.
    boolean
    boolean
    Gets whether this command should is treated as "raw".
    void
    setCancelled(boolean cancel)
    Cancels registering this command to Brigadier, but will remain in Bukkit Command Map.
    void
    setLiteral(com.mojang.brigadier.tree.LiteralCommandNode<S> literal)
    Sets the LiteralCommandNode used to register this command.
    void
    setRawCommand(boolean rawCommand)
    Sets whether this command should be treated as "raw".

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CommandRegisteredEvent

      public CommandRegisteredEvent(String commandLabel, BukkitBrigadierCommand<S> brigadierCommand, org.bukkit.command.Command command, com.mojang.brigadier.tree.RootCommandNode<S> root, com.mojang.brigadier.tree.LiteralCommandNode<S> literal, com.mojang.brigadier.tree.ArgumentCommandNode<S,String> defaultArgs)
  • Method Details

    • getCommandLabel

      public String getCommandLabel()
      Gets the command label of the Command being registered.
      Returns:
      the command label
    • getBrigadierCommand

      public BukkitBrigadierCommand<S> getBrigadierCommand()
      Gets the BukkitBrigadierCommand for the Command being registered. This can be used as the command executor or SuggestionProvider of a CommandNode to delegate to the Command being registered.
      Returns:
      the BukkitBrigadierCommand
    • getCommand

      public org.bukkit.command.Command getCommand()
      Gets the Command being registered.
      Returns:
      the Command
    • getRoot

      public com.mojang.brigadier.tree.RootCommandNode<S> getRoot()
      Gets the RootCommandNode which is being registered to.
      Returns:
      the RootCommandNode
    • getDefaultArgs

      public com.mojang.brigadier.tree.ArgumentCommandNode<S,String> getDefaultArgs()
      Gets the Bukkit APIs default arguments node (greedy string), for if you wish to reuse it.
      Returns:
      default arguments node
    • getLiteral

      public com.mojang.brigadier.tree.LiteralCommandNode<S> getLiteral()
      Gets the LiteralCommandNode to be registered for the Command.
      Returns:
      the LiteralCommandNode
    • setLiteral

      public void setLiteral(com.mojang.brigadier.tree.LiteralCommandNode<S> literal)
      Sets the LiteralCommandNode used to register this command. The default literal is mutable, so this is primarily if you want to completely replace the object.
      Parameters:
      literal - new node
    • isRawCommand

      public boolean isRawCommand()
      Gets whether this command should is treated as "raw".
      Returns:
      whether this command is treated as "raw"
      See Also:
    • setRawCommand

      public void setRawCommand(boolean rawCommand)
      Sets whether this command should be treated as "raw".

      A "raw" command will only use the node provided by this event for sending the command tree to the client. For execution purposes, the default greedy string execution of a standard Bukkit Command is used.

      On older versions of Paper, this was the default and only behavior of this event.

      Parameters:
      rawCommand - whether this command should be treated as "raw"
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancel)
      Cancels registering this command to Brigadier, but will remain in Bukkit Command Map. Can be used to hide a command from all players.
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Specified by:
      getHandlers in class org.bukkit.event.Event
    • getHandlerList

      @NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()