Solved TabCompleter and Plugin Instance with BukkitCommand

Discussion in 'Spigot Plugin Development' started by YourPalJake, May 27, 2018.

  1. Dear People,

    Currently, I am trying to make my own custom command system that registers the command through reflection.
    At the moment it works with only just giving the BukkitCommand but I can't seem to figure this out.

    #1 Tabcompleter
    So I am trying to make it so that I can set a tab completer for the command system but how?
    I searched everyone but I never stumbled to my answer.

    #2 Plugin instance
    I've noticed if I use this method of registering it doesn't allow me to pass a plugin instance.
    So if I try to do: /help MyPlugin then it would not show up the command.

    Can someone please give me some guidance on this matter.

    Best regards,
    YourPalJake
     
  2. Serializator

    Supporter

    Could you please show us what you have so that we can help you in a more targeted approach.
     
    • Like Like x 1
  3. The command arn't tied to any plugin?
     
    • Like Like x 1
  4. When you use the PluginCommand(The main.getCommand(“Command”); it registers in spigot under which plugin the command is registered. So if you do: /help myplugin then you get all the commands you have registered trough this method. But when I try it with reflection as far I know I never got a list of commands I registered trough my methods.
     
  5. You can just make the ReflectCommand extend PluginCommand instead of Command? and of course give it a plugin owner
     
    • Like Like x 1
  6. Ah actually you can extend PluginCommand can try implement PluginIdentifiableCommand
     
    • Like Like x 1
  7. Mhh, I am getting the error cannot inherit from final org.bukkit.command.PluginCommand
     
    • Funny Funny x 1
  8. Nvm, I found out you need to implement this, and then implement command:

    Code (Text):
    private final class ReflectCommand extends Command implements PluginIdentifiableCommand{
            private AbstractCommand exe = null;
            private Plugin plugin = null;

            protected ReflectCommand(String command, Plugin plugin){
                super(command);
                this.plugin = plugin;
            }

            public boolean execute(CommandSender sender, String label, String[] args){
                return false;
            }

            public Plugin getPlugin(){
                return null;
            }
        }

    Btw, I looked in Bukkit source and they have they also implement it for plugin command