protected void checkPermission(T player, Method method) throws CommandException { if (!hasPermission(method, player)) { throw new CommandPermissionsException(); } }
/** * 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; }
found = true; if (hasPermission(childMethod, player)) { Command childCmd = childMethod.getAnnotation(Command.class);
try { for (String permission : permissions) { if (((CommandsManager<CommandSender>) registeredWith).hasPermission(sender, permission)) { return true;
try { for (String perm : cmd.getPermissions()) { if (((CommandsManager<Object>) cmd.getRegisteredWith()).hasPermission(player, perm)) { return true;
/** * 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; }
@SuppressWarnings("unchecked") @Override public boolean testPermissionSilent(CommandSender sender) { if (permissions == null || permissions.length == 0) { return true; } if (registeredWith instanceof CommandsManager<?>) { try { for (String permission : permissions) { if (((CommandsManager<CommandSender>) registeredWith).hasPermission(sender, permission)) { return true; } } return false; } catch (Throwable ignore) { } } return super.testPermissionSilent(sender); } }
found = true; if (hasPermission(childMethod, player)) { Command childCmd = childMethod.getAnnotation(Command.class);
for(Map.Entry<String, Method> entry : map.entrySet()) { final String child = entry.getKey(); if(child.toLowerCase().startsWith(cmdNameLower) && hasPermission(entry.getValue(), player)) { children.add(child); if(!hasPermission(method, player)) { throw new CommandPermissionsException();
@Override @SuppressWarnings("unchecked") public boolean canSee(CommandSender player) { if (cmd.getPermissions() != null && cmd.getPermissions().length > 0) { if (cmd.getRegisteredWith() instanceof CommandsManager) { try { for (String perm : cmd.getPermissions()) { if (((CommandsManager<Object>) cmd.getRegisteredWith()).hasPermission(player, perm)) { return true; } } } catch (Throwable t) { // Doesn't take the CommandSender (Hooray for compile-time generics!), we have other methods at our disposal } } for (String perm : cmd.getPermissions()) { if (player.hasPermission(perm)) { return true; } } return false; } return true; }