for (Method method : cls.getMethods()) {
if (!method.isAnnotationPresent(Command.class)) {
continue;
}
Command cmd = method.getAnnotation(Command.class);
stream.println("|-");
stream.print("| " + prefix + cmd.aliases()[0]);
stream.print(" || ");
if (method.isAnnotationPresent(CommandPermissions.class)) {
CommandPermissions perms =
method.getAnnotation(CommandPermissions.class);
String[] permKeys = perms.value();
for (int i = 0; i < permKeys.length; ++i) {
if (i > 0) {
stream.print(", ");
}
stream.print(permKeys[i]);
}
}
stream.print(" || ");
boolean firstAlias = true;
if (cmd.aliases().length != 0) {
for (String alias : cmd.aliases()) {
if (!firstAlias) stream.print("<br />");
stream.print(prefix + alias);
firstAlias = false;
}
}
stream.print(" || ");
if (cmd.flags() != null && !cmd.flags().equals("")) {
stream.print(cmd.flags());
}
stream.print(" || ");
if (cmd.desc() != null && !cmd.desc().equals("")) {
stream.print(cmd.desc());
}
stream.println();
if (method.isAnnotationPresent(NestedCommand.class)) {
NestedCommand nested =
method.getAnnotation(NestedCommand.class);
Class<?>[] nestedClasses = nested.value();
writePermissionsWikiTable(stream,
Arrays.asList(nestedClasses),
prefix + cmd.aliases()[0] + " ");
}
}
}
}