Search in sources :

Example 1 with TabCompleter

use of org.bukkit.command.TabCompleter in project Fusion by GummyPvP.

the class BukkitCommand method tabComplete.

@Override
public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");
    List<String> completions = null;
    try {
        if (completer != null) {
            completions = completer.onTabComplete(sender, this, alias, args);
        }
        if (completions == null && executor instanceof TabCompleter) {
            completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args);
        }
    } catch (Throwable ex) {
        StringBuilder message = new StringBuilder();
        message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');
        for (String arg : args) {
            message.append(arg).append(' ');
        }
        message.deleteCharAt(message.length() - 1).append("' in plugin ").append(owningPlugin.getDescription().getFullName());
        throw new CommandException(message.toString(), ex);
    }
    if (completions == null) {
        return super.tabComplete(sender, alias, args);
    }
    return completions;
}
Also used : TabCompleter(org.bukkit.command.TabCompleter) CommandException(org.bukkit.command.CommandException)

Aggregations

CommandException (org.bukkit.command.CommandException)1 TabCompleter (org.bukkit.command.TabCompleter)1