/** * Returns whether a player has access to a command. * * @param method the method * @param player the player * @return true if permission is granted */ protected boolean hasPermission(Method method, T player) { CommandPermissions perms = method.getAnnotation(CommandPermissions.class); if (perms == null) { return true; } for (String perm : perms.value()) { if (hasPermission(player, perm)) { return true; } } return false; }
@Override public boolean testPermission(CommandLocals locals) { if (commandPermissions != null) { for (String perm : commandPermissions.value()) { if (builder.getAuthorizer().testPermission(locals, perm)) { return true; } } return false; } else { return true; } }
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); }
method.getAnnotation(CommandPermissions.class); String[] permKeys = perms.value(); for (int i = 0; i < permKeys.length; ++i) { if (i > 0) {
description.setPermissions(Arrays.asList(permHint.value()));
/** * Returns whether a player has access to a command. * * @param method the method * @param player the player * @return true if permission is granted */ protected boolean hasPermission(Method method, T player) { CommandPermissions perms = method.getAnnotation(CommandPermissions.class); if (perms == null) { return true; } for (String perm : perms.value()) { if (hasPermission(player, perm)) { return true; } } return false; }
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); } }