/** * Registers an executor. * * @param executor The executor to register. */ public void registerCommand(CommandExecutor executor) { for (Method method : executor.getClass().getMethods()) { Command annotation = method.getAnnotation(Command.class); if (annotation == null) { continue; } if (annotation.aliases().length == 0) { throw new IllegalArgumentException("Aliases array cannot be empty!"); } SimpleCommand command = new SimpleCommand(annotation, method, executor); for (String alias : annotation.aliases()) { // add command to map. It's faster to access it from the map than iterating to the whole list commands.put(defaultPrefix + alias.toLowerCase().replace(" ", ""), command); } // we need a list, too, because a HashMap is not ordered. commandList.add(command); } }