use of com.bencodez.advancedcore.api.command.CommandHandler in project VotingPlugin by Ben12345rocks.
the class AliasesTabCompleter method onTabComplete.
/*
* (non-Javadoc)
*
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
* CommandSender, org.bukkit.command.Command, java.lang.String,
* java.lang.String[])
*/
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] argsIn) {
ArrayList<String> msgArray = new ArrayList<String>();
msgArray.add("");
for (String arg : argsIn) {
msgArray.add(arg);
}
String[] args = ArrayUtils.getInstance().convert(msgArray);
ArrayList<String> tab = new ArrayList<String>();
Set<String> cmds = new HashSet<String>();
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
if (adminCommand) {
cmdHandlers.addAll(plugin.getAdminVoteCommand());
} else {
cmdHandlers.addAll(plugin.getVoteCommand());
}
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance().getTabCompleteOptions();
for (CommandHandler cmdHandle : cmdHandlers) {
if (cmdHandle.getArgs().length >= argsIn.length) {
for (String arg : cmdHandle.getArgs()[0].split("&")) {
if (cmd.getName().equalsIgnoreCase("vote" + arg) || cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
// plugin.debug("Found cmd... attempting to get tab
// complete");
args[0] = arg;
boolean argsMatch = true;
for (int i = 0; i < argsIn.length; i++) {
if (args.length >= i) {
if (!cmdHandle.argsMatch(args[i], i)) {
argsMatch = false;
}
}
}
if (argsMatch) {
cmds.addAll(cmdHandle.getTabCompleteOptions(sender, args, argsIn.length, tabCompletes));
}
}
}
}
}
for (String str : cmds) {
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
tab.add(str);
}
}
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
return tab;
}
Aggregations