public CommandInfo(Method method, Object provider) {
this.method = method;
this.provider = provider;
this.name = method.getName();
Command commandAnnotation = method.getAnnotation(Command.class);
if (commandAnnotation == null) {
throw new IllegalArgumentException("Method not annotated with command");
}
for (int i = 0; i < method.getParameterTypes().length; ++i) {
Class<?> parameterType = method.getParameterTypes()[i];
if (i == method.getParameterTypes().length - 1 && parameterType == EntityRef.class) {
clientEntityRequired = true;
} else {
String paramType = parameterType.getSimpleName().toLowerCase();
String paramName = getParamName(i);
if (paramName == null) {
paramName = "p" + i;
logger.warn("Parameter {} in method {} does not have a CommandParam annotation", i, method);
}
parameterNames.add(paramName);
parameterTypes.add(paramType);
}
}
this.runOnServer = commandAnnotation.runOnServer();
this.shortDescription = commandAnnotation.shortDescription();
this.helpText = commandAnnotation.helpText();
}