diff options
author | ElgarL <ElgarL@palmergames.com> | 2012-02-02 18:10:35 +0000 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2012-02-02 18:10:35 +0000 |
commit | fadc8455cbab9c83585a23a01f749674c5c868e3 (patch) | |
tree | 82c21de4709f2008b8c89881328d2fa2333f110b /EssentialsGroupManager/src/org | |
parent | cc6b2b7f8f5025363a13602c9b83fd1a63800b95 (diff) | |
download | Essentials-fadc8455cbab9c83585a23a01f749674c5c868e3.tar Essentials-fadc8455cbab9c83585a23a01f749674c5c868e3.tar.gz Essentials-fadc8455cbab9c83585a23a01f749674c5c868e3.tar.lz Essentials-fadc8455cbab9c83585a23a01f749674c5c868e3.tar.xz Essentials-fadc8455cbab9c83585a23a01f749674c5c868e3.zip |
Prevent getAllPlayersPermissions() processing a group more than once.
Improves performance when using complex inheritance structures.
Diffstat (limited to 'EssentialsGroupManager/src/org')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java index 7436bec70..bd2829f38 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -121,27 +121,34 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { // Add the players own permissions. playerPermArray.addAll(populatePerms(ph.getUser(userName).getPermissionList(), includeChildren)); + ArrayList<String> alreadyProcessed = new ArrayList<String>(); + // fetch all group permissions for (String group : getGroups(userName)) { - Set<String> groupPermArray = new HashSet<String>(); - - if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) { - // GlobalGroups - groupPermArray = populatePerms(GroupManager.getGlobalGroups().getGroupsPermissions(group), includeChildren); + // Don't process a group more than once. + if (!alreadyProcessed.contains(group)) { + alreadyProcessed.add(group); - } else { - // World Groups - groupPermArray = populatePerms(ph.getGroup(group).getPermissionList(), includeChildren); - } - - // Add all group permissions, unless negated by earlier permissions. - for (String perm : groupPermArray) { - boolean negated = (perm.startsWith("-")); - // Perm doesn't already exists and there is no negation for it - // or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms) - if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm)) - || (negated && !playerPermArray.contains(perm.substring(1)))) - playerPermArray.add(perm); + Set<String> groupPermArray = new HashSet<String>(); + + if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) { + // GlobalGroups + groupPermArray = populatePerms(GroupManager.getGlobalGroups().getGroupsPermissions(group), includeChildren); + + } else { + // World Groups + groupPermArray = populatePerms(ph.getGroup(group).getPermissionList(), includeChildren); + } + + // Add all group permissions, unless negated by earlier permissions. + for (String perm : groupPermArray) { + boolean negated = (perm.startsWith("-")); + // Perm doesn't already exists and there is no negation for it + // or It's a negated perm where a normal perm doesn't exists (don't allow inheritance to negate higher perms) + if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm)) + || (negated && !playerPermArray.contains(perm.substring(1)))) + playerPermArray.add(perm); + } } } |