More work on tab completion, see details.. #77

Completed:
- Jail check
- jail clear
- jail createcell
- jail deletecell
- Jail list
- jail listcells
- jail mute
This commit is contained in:
graywolf336
2015-06-01 21:14:01 -05:00
parent 73715c3d68
commit 019deea43a
35 changed files with 407 additions and 12 deletions

View File

@ -1,8 +1,13 @@
package com.graywolf336.jail.command.subcommands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Jail;
@ -63,4 +68,22 @@ public class JailCreateCellCommand implements Command {
return true;
}
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
//We shouldn't provide when they want a cell name
if(args.length >= 3) return Collections.emptyList();
List<String> results = new ArrayList<String>();
for(Jail j : jm.getJails()) {
if(args.length == 2 && StringUtil.startsWithIgnoreCase(j.getName(), args[1])) {
results.add(j.getName());
}else {
results.add(j.getName());
}
}
Collections.sort(results);
return results;
}
}