From 703131107d4e30c4611f31f41f8e2022b193561e Mon Sep 17 00:00:00 2001 From: ZerothAngel Date: Sun, 4 Sep 2011 16:21:49 -0700 Subject: [PATCH] Fix dinnerperms wildcard matching & group enumeration. --- .../bukkit/migration/DinnerPermsResolver.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java index cdbc7045b..ffceea3af 100644 --- a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java +++ b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java @@ -26,16 +26,11 @@ public class DinnerPermsResolver implements PermissionsResolver { return false; // Permissions are only registered for online players if ( player.hasPermission("*") || player.hasPermission(permission)) return true; - int i = 0; - while (i <= permission.length() + 1) { - int dotPos = permission.indexOf(".", i); - if (dotPos > -1) { - if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) - return true; - i += dotPos; - } else { - break; - } + int dotPos = permission.lastIndexOf("."); + while (dotPos > -1) { + if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) + return true; + dotPos = permission.lastIndexOf(".", dotPos - 1); } return false; } @@ -58,10 +53,10 @@ public class DinnerPermsResolver implements PermissionsResolver { List groupNames = new ArrayList(); for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) { String perm = permAttach.getPermission(); - if (!perm.startsWith(GROUP_PREFIX)) + if (!(perm.startsWith(GROUP_PREFIX) || permAttach.getValue())) continue; groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length())); } - return groupNames.toArray(new String[groupNames.size()]); + return groupNames.toArray(new String[0]); } }