Solved Tab completion

Discussion in 'Spigot Plugin Development' started by bys1, May 13, 2016.

Thread Status:
Not open for further replies.
  1. I'm trying to add tab completion.

    I have a class cmd implements CommandExecutor,TabCompleter with onCommand() and onTabComplete() methods.

    I've registered my command using getCommand().setExecutor();
    Can I also use getCommand().setTabExecutor(), or do I have to remove setExecutor then?
     
  2. TabExecutor extends CommandExecutor. It simply adds the onTabComplete method that you need to override.
     
  3. And do I have to use .setTabExecutor in my main and not .setExecutor?
     
  4. What? No... A TabExecutor is a CommandExecutor... I just explained that.. Register it like a normal CommandExecutor, like in my example link.
     
  5. But what would .setTabExecutor() do then?
     
  6. @BillyGalbreath correction:
    There's 2 interfaces, CommandExecutor and TabCompleter
    To make another class handle a command, use .setExecutor
    To make another class handle tab completion, use .setTabExecutor
    There's an interface, called TabExecutor, which simply extends CommandExecutor and TabCompleter. I believe if .setExecutor is called with a class that implements TabCompleter it also adds tab completion automatically, to make another class handle it for some unknown reason you then call .setTabCompleter
     
    • Like Like x 1
  7. I think I get it.

    I can make a class Mycommand implements CommandExecutor and register it with .setExecutor(),
    and I can make a second class MycommandTab implements TabCompleter and register it with .setTabCompleter();

    Is that correct?
     
  8. @bys1 indeed, although I personally prefer handling both in the same class
     
    • Agree Agree x 1
  9. Thank you.

    Question solved.

    Topic closed.
     
Thread Status:
Not open for further replies.