final String commandLowerCase = iCommand.toLowerCase();
for (Entry<Method, Object> entry : getConsoleMethods().entrySet()) {
final Method m = entry.getKey();
final String methodName = m.getName();
final ConsoleCommand ann = m.getAnnotation(ConsoleCommand.class);
final StringBuilder commandName = new StringBuilder();
char ch;
int commandWordCount = 1;
for (int i = 0; i < methodName.length(); ++i) {
ch = methodName.charAt(i);
if (Character.isUpperCase(ch)) {
commandName.append(" ");
ch = Character.toLowerCase(ch);
commandWordCount++;
}
commandName.append(ch);
}
if (!commandLowerCase.equals(commandName.toString()) && !commandLowerCase.startsWith(commandName.toString() + " ")) {
if (ann == null)
continue;
String[] aliases = ann.aliases();
if (aliases == null || aliases.length == 0)
continue;
boolean aliasMatch = false;
for (String alias : aliases) {
if (iCommand.startsWith(alias.split(" ")[0])) {
aliasMatch = true;
commandWordCount = 1;
break;
}
}
if (!aliasMatch)
continue;
}
Object[] methodArgs;
// BUILD PARAMETERS
if (ann != null && !ann.splitInWords()) {
methodArgs = new String[] { iCommand.substring(iCommand.indexOf(' ') + 1) };
} else {
final int actualParamCount = commandWords.length - commandWordCount;
if (m.getParameterTypes().length > actualParamCount) {
// METHOD PARAMS AND USED PARAMS MISMATCH: CHECK FOR OPTIONALS