summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2012-02-02 18:10:35 +0000
committerElgarL <ElgarL@palmergames.com>2012-02-02 18:10:35 +0000
commit76ba5caeec462b53eb9bffedec3c67b646eebb1c (patch)
tree4dd5e71861c038b6fe30496cff657c08780a87b2 /EssentialsGroupManager
parenta0103afde373e581ce4028b7c57bef7b21bfc780 (diff)
downloadEssentials-76ba5caeec462b53eb9bffedec3c67b646eebb1c.tar
Essentials-76ba5caeec462b53eb9bffedec3c67b646eebb1c.tar.gz
Essentials-76ba5caeec462b53eb9bffedec3c67b646eebb1c.tar.lz
Essentials-76ba5caeec462b53eb9bffedec3c67b646eebb1c.tar.xz
Essentials-76ba5caeec462b53eb9bffedec3c67b646eebb1c.zip
Prevent getAllPlayersPermissions() processing a group more than once.
Improves performance when using complex inheritance structures.
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java43
2 files changed, 27 insertions, 19 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index e48365de5..0ef3add6f 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -134,4 +134,5 @@ v 1.9:
- vanish.standard
- Track the 'onPlayerChangeWorld' event as some teleports seem to not be triggering a world move.
- Catch all errors in badly formatted groups.
- - Fix a bug with getWorldData return the main world data for all mirrors, instead of the worlds parent data. \ No newline at end of file
+ - Fix a bug with getWorldData return the main world data for all mirrors, instead of the worlds parent data.
+ - Prevent getAllPlayersPermissions() processing a group more than once. Improves performance when using complex inheritance structures. \ No newline at end of file
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);
+ }
}
}