mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-18 09:51:17 +02:00
Add tab completion to "ncp top".
This commit is contained in:
parent
58f84028f3
commit
427a877b17
@ -22,12 +22,23 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.ViolationHistory;
|
||||
import fr.neatmonster.nocheatplus.checks.ViolationHistory.VLView;
|
||||
import fr.neatmonster.nocheatplus.command.BaseCommand;
|
||||
import fr.neatmonster.nocheatplus.command.CommandUtil;
|
||||
import fr.neatmonster.nocheatplus.hooks.APIUtils;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.FCFSComparator;
|
||||
|
||||
public class TopCommand extends BaseCommand{
|
||||
|
||||
private static final String[][] comparatorArgs = new String[][]{
|
||||
//{"-player", "-name", "-playername"},
|
||||
//{"-check", "-type", "-checktype}
|
||||
{"-sumvl", "-sum", "-vl"},
|
||||
{"-n", "-number", "-num", "-nvl"},
|
||||
{"-avgvl", "-avg", "-avl", "-av", "-average", "-averagevl", "-avvl"},
|
||||
{"-maxvl", "-max", "-maximum", "-maximumvl"},
|
||||
{"-time", "-"},
|
||||
};
|
||||
|
||||
protected static class PrimaryThreadWorker implements Runnable{
|
||||
private final Collection<CheckType> checkTypes;
|
||||
private final CommandSender sender;
|
||||
@ -198,6 +209,18 @@ public class TopCommand extends BaseCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Tab completion (!).
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
String arg = args[args.length - 1];
|
||||
if (arg.startsWith("-")) {
|
||||
while (arg.startsWith("-")) {
|
||||
arg = arg.substring(1);
|
||||
}
|
||||
arg = "-" + arg;
|
||||
return CommandUtil.getTabMatches(arg.toLowerCase(), comparatorArgs);
|
||||
} else {
|
||||
return CommandUtil.getCheckTypeTabMatches(arg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user