Interface Commodore
-
public interface CommodoreUtility for using Minecraft's 1.13 'brigadier' library in Bukkit plugins.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Collection<String>getAliases(org.bukkit.command.Command command)Gets all of the aliases known for the given command.org.bukkit.command.CommandSendergetBukkitSender(Object commandWrapperListener)Gets the CommandSender associated with the passed CommandWrapperListener.com.mojang.brigadier.CommandDispatchergetDispatcher()Gets the current command dispatcher instance.List<com.mojang.brigadier.tree.LiteralCommandNode<?>>getRegisteredNodes()Gets a list of all nodes registered to theCommandDispatcherby this instance.default voidregister(com.mojang.brigadier.builder.LiteralArgumentBuilder<?> argumentBuilder)Registers the provided argument data to the dispatcher.voidregister(com.mojang.brigadier.tree.LiteralCommandNode<?> node)Registers the provided argument data to the dispatcher.default voidregister(org.bukkit.command.Command command, com.mojang.brigadier.builder.LiteralArgumentBuilder<?> argumentBuilder)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.default voidregister(org.bukkit.command.Command command, com.mojang.brigadier.builder.LiteralArgumentBuilder<?> argumentBuilder, Predicate<? super org.bukkit.entity.Player> permissionTest)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.voidregister(org.bukkit.command.Command command, com.mojang.brigadier.tree.LiteralCommandNode<?> node)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.voidregister(org.bukkit.command.Command command, com.mojang.brigadier.tree.LiteralCommandNode<?> node, Predicate<? super org.bukkit.entity.Player> permissionTest)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.
-
-
-
Method Detail
-
getDispatcher
com.mojang.brigadier.CommandDispatcher getDispatcher()
Gets the current command dispatcher instance.CraftBukkit doesn't use the same dispatcher instance throughout the runtime of the server. The dispatcher instance is completely wiped (and replaced with a new instance) every time new plugins are loaded.
- Returns:
- the command dispatcher
-
getBukkitSender
org.bukkit.command.CommandSender getBukkitSender(Object commandWrapperListener)
Gets the CommandSender associated with the passed CommandWrapperListener.Minecraft calls brigadier command handlers with an instance of CommandWrapperListener, which cannot be accessed without accessing nms code. This method takes an Object as parameter, but the only type actually accepted is those from the S type provided by Minecraft.
- Parameters:
commandWrapperListener- the CommandWrapperListener instance from nms.- Returns:
- the CommandWrapperListener wrapped as a CommandSender.
-
getRegisteredNodes
List<com.mojang.brigadier.tree.LiteralCommandNode<?>> getRegisteredNodes()
Gets a list of all nodes registered to theCommandDispatcherby this instance.- Returns:
- a list of all registered nodes.
-
register
void register(org.bukkit.command.Command command, com.mojang.brigadier.tree.LiteralCommandNode<?> node, Predicate<? super org.bukkit.entity.Player> permissionTest)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.Additionally applies the CraftBukkit
SuggestionProviderto all arguments within the node, so ASK_SERVER suggestions can continue to function for the command.Players will only be sent argument data if they pass the provided
permissionTest.- Parameters:
command- the command to read aliases fromnode- the argument datapermissionTest- the predicate to check whether players should be sent argument data
-
register
default void register(org.bukkit.command.Command command, com.mojang.brigadier.builder.LiteralArgumentBuilder<?> argumentBuilder, Predicate<? super org.bukkit.entity.Player> permissionTest)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.Additionally applies the CraftBukkit
SuggestionProviderto all arguments within the node, so ASK_SERVER suggestions can continue to function for the command.Players will only be sent argument data if they pass the provided
permissionTest.- Parameters:
command- the command to read aliases fromargumentBuilder- the argument data, in a builder formpermissionTest- the predicate to check whether players should be sent argument data
-
register
void register(org.bukkit.command.Command command, com.mojang.brigadier.tree.LiteralCommandNode<?> node)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.Additionally applies the CraftBukkit
SuggestionProviderto all arguments within the node, so ASK_SERVER suggestions can continue to function for the command.- Parameters:
command- the command to read aliases fromnode- the argument data
-
register
default void register(org.bukkit.command.Command command, com.mojang.brigadier.builder.LiteralArgumentBuilder<?> argumentBuilder)Registers the provided argument data to the dispatcher, against all aliases defined for thecommand.Additionally applies the CraftBukkit
SuggestionProviderto all arguments within the node, so ASK_SERVER suggestions can continue to function for the command.- Parameters:
command- the command to read aliases fromargumentBuilder- the argument data, in a builder form
-
register
void register(com.mojang.brigadier.tree.LiteralCommandNode<?> node)
Registers the provided argument data to the dispatcher.Equivalent to calling
CommandDispatcher.register(LiteralArgumentBuilder).Prefer using
register(Command, LiteralCommandNode).- Parameters:
node- the argument data
-
register
default void register(com.mojang.brigadier.builder.LiteralArgumentBuilder<?> argumentBuilder)
Registers the provided argument data to the dispatcher.Equivalent to calling
CommandDispatcher.register(LiteralArgumentBuilder).Prefer using
register(Command, LiteralArgumentBuilder).- Parameters:
argumentBuilder- the argument data
-
getAliases
static Collection<String> getAliases(org.bukkit.command.Command command)
Gets all of the aliases known for the given command.This will include the main label, as well as defined aliases, and aliases including the fallback prefix added by Bukkit.
- Parameters:
command- the command- Returns:
- the aliases
-
-