mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-15 19:14:18 +02:00
Allow alternative command handler to also pass tab complete.
This commit is contained in:
@@ -58,6 +58,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.command.defaults.VanillaCommand;
|
import org.bukkit.command.defaults.VanillaCommand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -336,6 +337,35 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
|
|||||||
registerListeners(pm);
|
registerListeners(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user