From f6839594208bf0d78a391c79bc58e85e67b4eb21 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 29 Jan 2011 09:01:21 -0800 Subject: [PATCH] Added hierarchical permissions support to permission resolvers, improved Permissions support. --- .../bukkit/migration/ConfigurationPermissionsResolver.java | 7 +++++++ .../bukkit/migration/FlatFilePermissionsResolver.java | 7 +++++++ .../bukkit/migration/GroupUsersPemissionsResolver.java | 6 ++++++ .../sk89q/bukkit/migration/NijiPermissionsResolver.java | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java b/src/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java index d2c4aa6dc..50185d3cb 100644 --- a/src/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java +++ b/src/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java @@ -94,6 +94,13 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { } public boolean hasPermission(String player, String permission) { + int dotPos = permission.lastIndexOf("."); + if (dotPos > -1) { + if (hasPermission(player, permission.substring(0, dotPos))) { + return true; + } + } + Set perms = userPermissionsCache.get(player.toLowerCase()); if (perms == null) { return defaultPermissionsCache.contains(permission) diff --git a/src/com/sk89q/bukkit/migration/FlatFilePermissionsResolver.java b/src/com/sk89q/bukkit/migration/FlatFilePermissionsResolver.java index e75069c2f..1484117eb 100644 --- a/src/com/sk89q/bukkit/migration/FlatFilePermissionsResolver.java +++ b/src/com/sk89q/bukkit/migration/FlatFilePermissionsResolver.java @@ -153,6 +153,13 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } public boolean hasPermission(String player, String permission) { + int dotPos = permission.lastIndexOf("."); + if (dotPos > -1) { + if (hasPermission(player, permission.substring(0, dotPos))) { + return true; + } + } + Set perms = userPermissionsCache.get(player.toLowerCase()); if (perms == null) { return defaultPermissionsCache.contains(permission) diff --git a/src/com/sk89q/bukkit/migration/GroupUsersPemissionsResolver.java b/src/com/sk89q/bukkit/migration/GroupUsersPemissionsResolver.java index 436b4cff6..b12e0546c 100644 --- a/src/com/sk89q/bukkit/migration/GroupUsersPemissionsResolver.java +++ b/src/com/sk89q/bukkit/migration/GroupUsersPemissionsResolver.java @@ -55,6 +55,12 @@ public class GroupUsersPemissionsResolver implements PermissionsResolver { try { Player player = server.getPlayer(name); if (player == null) return false; + int dotPos = permission.lastIndexOf("."); + if (dotPos > -1) { + if (hasPermission(name, permission.substring(0, dotPos))) { + return true; + } + } return groupUsers.playerCanUseCommand(player, permission); } catch (Throwable t) { t.printStackTrace(); diff --git a/src/com/sk89q/bukkit/migration/NijiPermissionsResolver.java b/src/com/sk89q/bukkit/migration/NijiPermissionsResolver.java index 3c313ba67..eeba26297 100644 --- a/src/com/sk89q/bukkit/migration/NijiPermissionsResolver.java +++ b/src/com/sk89q/bukkit/migration/NijiPermissionsResolver.java @@ -67,7 +67,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { try { Player player = server.getPlayer(name); if (player == null) return false; - return group.equals(api.Security.getGroup(player.getName())); + return api.Security.inGroup(name, group); } catch (Throwable t) { t.printStackTrace(); return false;