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
ConstructorsConstructorDescriptionCommandRegisteredEvent(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 TypeMethodDescriptionGets theBukkitBrigadierCommandfor theCommandbeing registered.org.bukkit.command.CommandGets theCommandbeing registered.Gets the command label of theCommandbeing registered.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.HandlerListcom.mojang.brigadier.tree.LiteralCommandNode<S>Gets theLiteralCommandNodeto be registered for theCommand.com.mojang.brigadier.tree.RootCommandNode<S>getRoot()Gets theRootCommandNodewhich is being registered to.booleanbooleanGets whether this command should is treated as "raw".voidsetCancelled(boolean cancel) Cancels registering this command to Brigadier, but will remain in Bukkit Command Map.voidsetLiteral(com.mojang.brigadier.tree.LiteralCommandNode<S> literal) Sets theLiteralCommandNodeused to register this command.voidsetRawCommand(boolean rawCommand) Sets whether this command should be treated as "raw".Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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
Gets the command label of theCommandbeing registered.- Returns:
- the command label
-
getBrigadierCommand
Gets theBukkitBrigadierCommandfor theCommandbeing registered. This can be used as thecommand executororSuggestionProviderof aCommandNodeto delegate to theCommandbeing registered.- Returns:
- the
BukkitBrigadierCommand
-
getCommand
public org.bukkit.command.Command getCommand()Gets theCommandbeing registered.- Returns:
- the
Command
-
getRoot
Gets theRootCommandNodewhich is being registered to.- Returns:
- the
RootCommandNode
-
getDefaultArgs
Gets the Bukkit APIs default arguments node (greedy string), for if you wish to reuse it.- Returns:
- default arguments node
-
getLiteral
Gets theLiteralCommandNodeto be registered for theCommand.- Returns:
- the
LiteralCommandNode
-
setLiteral
Sets theLiteralCommandNodeused 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
Commandis 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:
isCancelledin interfaceorg.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:
setCancelledin interfaceorg.bukkit.event.Cancellable
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()- Specified by:
getHandlersin classorg.bukkit.event.Event
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()
-