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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user