summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-08-15 21:58:23 +0100
committerKHobbits <rob@khobbits.co.uk>2013-08-15 21:58:23 +0100
commit75fe543579a5280293807b15eb4511641dd84769 (patch)
tree6f4040391d2ceb876c9f4d98fbe5fd6ac3521721
parent7bc84d6cad97a9fa8338ac2146e819a0b382bc82 (diff)
downloadEssentials-75fe543579a5280293807b15eb4511641dd84769.tar
Essentials-75fe543579a5280293807b15eb4511641dd84769.tar.gz
Essentials-75fe543579a5280293807b15eb4511641dd84769.tar.lz
Essentials-75fe543579a5280293807b15eb4511641dd84769.tar.xz
Essentials-75fe543579a5280293807b15eb4511641dd84769.zip
Allow alternative command handler to also pass tab complete.
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java30
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);