diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-08-15 21:58:23 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-08-15 21:58:23 +0100 |
commit | 009ea37d1cc276fd6a5ae10288aea655d1ea1cde (patch) | |
tree | 74d909a787f793e974ec3df143f39010a0ec4d90 /Essentials | |
parent | 40b5e7fcdf649c7a8745a01fe72281dda2ef907d (diff) | |
download | Essentials-009ea37d1cc276fd6a5ae10288aea655d1ea1cde.tar Essentials-009ea37d1cc276fd6a5ae10288aea655d1ea1cde.tar.gz Essentials-009ea37d1cc276fd6a5ae10288aea655d1ea1cde.tar.lz Essentials-009ea37d1cc276fd6a5ae10288aea655d1ea1cde.tar.xz Essentials-009ea37d1cc276fd6a5ae10288aea655d1ea1cde.zip |
Allow alternative command handler to also pass tab complete.
Diffstat (limited to 'Essentials')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 437aac85b..86ba3c48d 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -58,6 +58,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.command.SimpleCommandMap; +import org.bukkit.command.TabCompleter; import org.bukkit.command.defaults.VanillaCommand; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -337,6 +338,35 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials } @Override + public List<String> onTabComplete(CommandSender sender, + Command command, + String commandLabel, + String[] args) + { + // Allow plugins to override the command via onCommand + if (!getSettings().isCommandOverridden(command.getName()) && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName()))) + { + final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel); + if (pc != null) + { + try + { + TabCompleter completer = pc.getTabCompleter(); + if (completer != null) + { + return completer.onTabComplete(sender, command, commandLabel, args); + } + } + catch (final Exception ex) + { + Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex); + } + } + } + return null; + } + + @Override public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args) { return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null); |