mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-05-20 06:13:24 +00:00
Prevent getAllPlayersPermissions() processing a group more than once.
Improves performance when using complex inheritance structures.
This commit is contained in:
parent
a0103afde3
commit
76ba5caeec
2 changed files with 27 additions and 19 deletions
|
@ -134,4 +134,5 @@ v 1.9:
|
||||||
- vanish.standard
|
- vanish.standard
|
||||||
- Track the 'onPlayerChangeWorld' event as some teleports seem to not be triggering a world move.
|
- Track the 'onPlayerChangeWorld' event as some teleports seem to not be triggering a world move.
|
||||||
- Catch all errors in badly formatted groups.
|
- 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.
|
- 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.
|
|
@ -121,27 +121,34 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
// Add the players own permissions.
|
// Add the players own permissions.
|
||||||
playerPermArray.addAll(populatePerms(ph.getUser(userName).getPermissionList(), includeChildren));
|
playerPermArray.addAll(populatePerms(ph.getUser(userName).getPermissionList(), includeChildren));
|
||||||
|
|
||||||
|
ArrayList<String> alreadyProcessed = new ArrayList<String>();
|
||||||
|
|
||||||
// fetch all group permissions
|
// fetch all group permissions
|
||||||
for (String group : getGroups(userName)) {
|
for (String group : getGroups(userName)) {
|
||||||
Set<String> groupPermArray = new HashSet<String>();
|
// Don't process a group more than once.
|
||||||
|
if (!alreadyProcessed.contains(group)) {
|
||||||
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
|
alreadyProcessed.add(group);
|
||||||
// GlobalGroups
|
|
||||||
groupPermArray = populatePerms(GroupManager.getGlobalGroups().getGroupsPermissions(group), includeChildren);
|
|
||||||
|
|
||||||
} else {
|
Set<String> groupPermArray = new HashSet<String>();
|
||||||
// World Groups
|
|
||||||
groupPermArray = populatePerms(ph.getGroup(group).getPermissionList(), includeChildren);
|
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
|
||||||
}
|
// GlobalGroups
|
||||||
|
groupPermArray = populatePerms(GroupManager.getGlobalGroups().getGroupsPermissions(group), includeChildren);
|
||||||
// Add all group permissions, unless negated by earlier permissions.
|
|
||||||
for (String perm : groupPermArray) {
|
} else {
|
||||||
boolean negated = (perm.startsWith("-"));
|
// World Groups
|
||||||
// Perm doesn't already exists and there is no negation for it
|
groupPermArray = populatePerms(ph.getGroup(group).getPermissionList(), includeChildren);
|
||||||
// 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))))
|
// Add all group permissions, unless negated by earlier permissions.
|
||||||
playerPermArray.add(perm);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue