diff options
author | ElgarL <ElgarL@palmergames.com> | 2011-09-26 21:52:32 +0100 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2011-09-26 21:52:32 +0100 |
commit | a39a904c8ae8972a970771ef2c0eef7e2bd41d10 (patch) | |
tree | 3a58c6b0300a07bcd2ecd1cbffe38f65b8b7c705 /EssentialsGroupManager/src/org/anjocaido/groupmanager | |
parent | 1d38b728350e3c7b556ef402c339472e83661cd0 (diff) | |
download | Essentials-a39a904c8ae8972a970771ef2c0eef7e2bd41d10.tar Essentials-a39a904c8ae8972a970771ef2c0eef7e2bd41d10.tar.gz Essentials-a39a904c8ae8972a970771ef2c0eef7e2bd41d10.tar.lz Essentials-a39a904c8ae8972a970771ef2c0eef7e2bd41d10.tar.xz Essentials-a39a904c8ae8972a970771ef2c0eef7e2bd41d10.zip |
Optimized getAllPlayersPermissions and fixed pushing unknown perms to
superperms.
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java | 71 |
1 files changed, 11 insertions, 60 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java index 5830f0c88..cb9fdf628 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -81,73 +81,24 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { } /** - * Returns All permissions (including inheritance) of player name. + * Returns All permissions (including inheritance and sub groups) for the player. + * * @param userName * @return */ @Override public List<String> getAllPlayersPermissions(String userName) { - User user = ph.getUser(userName); - List<String> playerPermArray = new ArrayList<String>(user.getPermissionList()); - List<String> playerMainGroupPermArray = new ArrayList<String>(user.getGroup().getPermissionList()); - List<String> subGroupsPermArray = new ArrayList<String>(); - List<String> returnPermArray = new ArrayList<String>(); + List<String> playerPermArray = new ArrayList<String>(ph.getUser(userName).getPermissionList()); - for (String subGroup : user.subGroupListStringCopy()) { - subGroupsPermArray.addAll(ph.getGroup(subGroup).getPermissionList()); + for (String group : getGroups(userName)) { + for (String perm : ph.getGroup(group).getPermissionList()) { + if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm))) + playerPermArray.add(perm); + } } - - for (String permission : subGroupsPermArray) { - /* - * Add each Negated permission - * unless it's being overridden by a higher permission - */ - if (permission.startsWith("-") - && !playerMainGroupPermArray.contains(permission.substring(1)) - && !playerPermArray.contains(permission.substring(1)) - && !playerMainGroupPermArray.contains("*") - && !playerPermArray.contains("*")) { - if (!returnPermArray.contains(permission)) { - returnPermArray.add(permission); - } - } else - if (!returnPermArray.contains(permission) - && !playerMainGroupPermArray.contains("-"+permission) - && !playerPermArray.contains("-"+permission)) { - returnPermArray.add(permission); - } - } - - for (String permission : playerMainGroupPermArray) { - /* - * Add each Negated permission - * unless it's being overridden by a higher permission - */ - if (permission.startsWith("-") - && !playerPermArray.contains(permission.substring(1)) - && !playerMainGroupPermArray.contains("*") - && !playerPermArray.contains("*")) { - if (!returnPermArray.contains(permission)) { - returnPermArray.add(permission); - } - } else - if (!returnPermArray.contains(permission) - && !playerPermArray.contains("-"+permission)) { - returnPermArray.add(permission); - } - } - - for (String permission : playerPermArray) { - /* - * Add each permission - */ - if (!returnPermArray.contains(permission)) { - returnPermArray.add(permission); - } - } - - return returnPermArray; + + return playerPermArray; } /** @@ -159,7 +110,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { * And verify the player 'MyAdmin', which is Admin, it will return true for both * Admin or Moderator groups. * - * Mas if you haave a player 'MyModerator', which is Moderator, + * Mas if you have a player 'MyModerator', which is Moderator, * it will give false if you pass Admin in group parameter. * * @param name |