@Override
  public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
      return StringUtil.copyPartialMatches(
          args[0], WHITELIST_SUBCOMMANDS, new ArrayList<String>(WHITELIST_SUBCOMMANDS.size()));
    } else if (args.length == 2) {
      if (args[0].equalsIgnoreCase("add")) {
        List<String> completions = new ArrayList<String>();
        for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
          String name = player.getName();
          if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) {
            completions.add(name);
          }
        }
        return completions;
      } else if (args[0].equalsIgnoreCase("remove")) {
        List<String> completions = new ArrayList<String>();
        for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
          String name = player.getName();
          if (StringUtil.startsWithIgnoreCase(name, args[1])) {
            completions.add(name);
          }
        }
        return completions;
      }
    }
    return ImmutableList.of();
  }
예제 #2
0
 @Override
 public List<String> onTabComplete(
     CommandSender sender, Command command, String alias, String[] args) {
   switch (args.length) {
     case 1:
       Set<String> playerNames = UserManager.getPlayerNames();
       return StringUtil.copyPartialMatches(
           args[0], playerNames, new ArrayList<String>(playerNames.size()));
     default:
       return ImmutableList.of();
   }
 }
예제 #3
0
  @Override
  public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
      return StringUtil.copyPartialMatches(
          args[0], GAMEMODE_NAMES, new ArrayList<String>(GAMEMODE_NAMES.size()));
    }

    return ImmutableList.of();
  }
예제 #4
0
 private List<String> partial(String token, Collection<String> from) {
   return StringUtil.copyPartialMatches(token, from, new ArrayList<String>(from.size()));
 }