• Type: New Feature
    • Resolution: Unresolved
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • 2993-Spigot-5bde311-b5eb2f5 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
    • Yes

      Commands registered through brigadier to the CommandDispatcher are wrapped with a VanillaCommandWrapper in the Bukkit command map (CraftServer#setVanillaCommands). Injecting description, permission, aliases etc to the VanillaCommandWrapper is trivial, but it is not possible to assign it to a plugin without VanillaCommandWrapper implementing PluginIdentifiableCommand. As VanillaCommandWrapper is final this is not possible.

      I have managed to make a wrapper for VanillaCommandWrapper which implements PluginIdentifiableCommand and is injected into Bukkit's command map in place of the VanillaCommandWrapper. This does assign the command to my plugin, however Bukkit (CraftServer#syncCommands) creates a BukkitCommandWrapper around the custom VanillaCommandWrapper as it's no longer an instance of VanillaCommandWrapper. This means suggestions are not provided natively by brigadier, but they're the List<String> suggestions system that Bukkit uses. This causes lots of weird behaviour when using these commands, especially with suggestions in entity selectors.

      Would it be possible to create an interface to denote vanilla commands instead of just testing for instances of VanillaCommandWrapper? My proposed solution looks like this:

      package org.bukkit.command;
      
      public interface VanillaCommand {
      	public LiteralCommandNode getNode();
      }
      

      VanillaCommandWrapper then implements this interface as well as my custom wrapper.

      CraftServer's syncCommands can now test for an instance of this interface instead of VanillaCommandWrapper and use the getNode method to access the LiteralNode instead of the vanillaCommand field.

      This would allow my brigadier commands to forego BukkitCommandWrappers and as such tab complete completely natively while also being registered as belonging to my plugin in the help menu.

      Thanks.

        1. help info.png
          help info.png
          166 kB
        2. native.gif
          native.gif
          2.77 MB
        3. non-native.gif
          non-native.gif
          2.49 MB

            Assignee:
            Unassigned
            Reporter:
            Eoghan Spillane
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: