Interface Commodore


  • public interface Commodore
    Utility 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.CommandSender getBukkitSender​(Object commandWrapperListener)
      Gets the CommandSender associated with the passed CommandWrapperListener.
      com.mojang.brigadier.CommandDispatcher getDispatcher()
      Gets the current command dispatcher instance.
      List<com.mojang.brigadier.tree.LiteralCommandNode<?>> getRegisteredNodes()
      Gets a list of all nodes registered to the CommandDispatcher by this instance.
      default void register​(com.mojang.brigadier.builder.LiteralArgumentBuilder<?> argumentBuilder)
      Registers the provided argument data to the dispatcher.
      void register​(com.mojang.brigadier.tree.LiteralCommandNode<?> node)
      Registers the provided argument data to the dispatcher.
      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 the command.
      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 the command.
      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 the command.
      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 the command.
    • 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 the CommandDispatcher by 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 the command.

        Additionally applies the CraftBukkit SuggestionProvider to 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 from
        node - the argument data
        permissionTest - 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 the command.

        Additionally applies the CraftBukkit SuggestionProvider to 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 from
        argumentBuilder - the argument data, in a builder form
        permissionTest - 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 the command.

        Additionally applies the CraftBukkit SuggestionProvider to all arguments within the node, so ASK_SERVER suggestions can continue to function for the command.

        Parameters:
        command - the command to read aliases from
        node - 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 the command.

        Additionally applies the CraftBukkit SuggestionProvider to all arguments within the node, so ASK_SERVER suggestions can continue to function for the command.

        Parameters:
        command - the command to read aliases from
        argumentBuilder - 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