protected CharSequence getArguments(Command cmd) { final String flags = cmd.flags(); final StringBuilder command2 = new StringBuilder(); if (!flags.isEmpty()) { String flagString = flags.replaceAll(".:", ""); if (!flagString.isEmpty()) { command2.append("[-"); for (int i = 0; i < flagString.length(); ++i) { command2.append(flagString.charAt(i)); } command2.append("] "); } } command2.append(cmd.usage()); return command2; }
public boolean registerAll(List<Command> registered) { List<CommandInfo> toRegister = new ArrayList<>(); for (Command command : registered) { List<String> permissions = null; Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]); Map<String, Method> childMethods = commands.getMethods().get(cmdMethod); if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) { permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value()); } else if (cmdMethod != null && childMethods != null && !childMethods.isEmpty()) { permissions = new ArrayList<>(); for (Method m : childMethods.values()) { if (m.isAnnotationPresent(CommandPermissions.class)) { permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value())); } } } toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions == null ? null : permissions.toArray(new String[permissions.size()]))); } return register(toRegister); }
@Override public void updateDescription(Object object, Method method, ParameterData[] parameters, SimpleDescription description) { Command annotation = method.getAnnotation(Command.class); // Handle the case for old commands where no usage is set and all of its // parameters are provider bindings, so its usage information would // be blank and would imply that there were no accepted parameters if (annotation != null && annotation.usage().isEmpty() && (annotation.min() > 0 || annotation.max() > 0)) { boolean hasUserParameters = false; for (ParameterData parameter : parameters) { if (parameter.getBinding().getBehavior(parameter) != BindingBehavior.PROVIDES) { hasUserParameters = true; break; } } if (!hasUserParameters) { description.overrideUsage("(unknown usage information)"); } } }
final String desc = cmd.desc(); final String usage = cmd.usage(); if (usage.isEmpty()) { descs.put(commandName, desc);
protected CharSequence getArguments(Command cmd) { final String flags = cmd.flags(); final StringBuilder command2 = new StringBuilder(); if (!flags.isEmpty()) { String flagString = flags.replaceAll(".:", ""); if (!flagString.isEmpty()) { command2.append("[-"); for (int i = 0; i < flagString.length(); ++i) { command2.append(flagString.charAt(i)); } command2.append("] "); } } command2.append(cmd.usage()); return command2; }
public boolean registerAll(List<Command> registered) { List<CommandInfo> toRegister = new ArrayList<CommandInfo>(); for (Command command : registered) { String[] permissions = null; Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]); if(cmdMethod != null) { if(cmdMethod.isAnnotationPresent(CommandPermissions.class)) { permissions = cmdMethod.getAnnotation(CommandPermissions.class).value(); } } toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions)); } return register(toRegister); } }
final String desc = cmd.desc(); final String usage = cmd.usage(); if (usage.isEmpty()) { descs.put(commandName, desc);