mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-09 18:07:37 +01:00
Auto sort permissions on load to speed up population of superperms.
Negating a parent node after adding all nodes with * will now correctly remove all child nodes of that parent before populating superperms. eg. - '*' - -vanish.* - vanish.standard
This commit is contained in:
parent
2c8aa20542
commit
5b4966c888
@ -125,4 +125,10 @@ v 1.9:
|
|||||||
- Fixed an infinite loop error when using '/manudel' on a logged in player. It caused setDefaultGroup to trigger a bukkit update when no GM User existed yet.
|
- Fixed an infinite loop error when using '/manudel' on a logged in player. It caused setDefaultGroup to trigger a bukkit update when no GM User existed yet.
|
||||||
- do not allow inherited permissions to negate higher perms.
|
- do not allow inherited permissions to negate higher perms.
|
||||||
- Fixed a bug when pushing superperms in the wrong order.
|
- Fixed a bug when pushing superperms in the wrong order.
|
||||||
- Fix players retaining permissions when demoted.
|
- Fix players retaining permissions when demoted.
|
||||||
|
- Auto sort permissions on load to speed up population of superperms.
|
||||||
|
- Negating a parent node after adding all nodes with * will now correctly remove all child nodes of that parent before populating superperms.
|
||||||
|
eg.
|
||||||
|
- '*'
|
||||||
|
- -vanish.*
|
||||||
|
- vanish.standard
|
@ -451,7 +451,7 @@ public class WorldDataHolder {
|
|||||||
Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
|
Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
|
||||||
Group thisGrp = ph.createGroup(groupKey);
|
Group thisGrp = ph.createGroup(groupKey);
|
||||||
if (thisGrp == null) {
|
if (thisGrp == null) {
|
||||||
throw new IllegalArgumentException("I think this user was declared more than once: " + groupKey + " in file: " + groupsFile.getPath());
|
throw new IllegalArgumentException("I think this Group was declared more than once: " + groupKey + " in file: " + groupsFile.getPath());
|
||||||
}
|
}
|
||||||
if (thisGroupNode.get("default") == null) {
|
if (thisGroupNode.get("default") == null) {
|
||||||
thisGroupNode.put("default", false);
|
thisGroupNode.put("default", false);
|
||||||
@ -467,20 +467,22 @@ public class WorldDataHolder {
|
|||||||
//PERMISSIONS NODE
|
//PERMISSIONS NODE
|
||||||
if (thisGroupNode.get("permissions") == null) {
|
if (thisGroupNode.get("permissions") == null) {
|
||||||
thisGroupNode.put("permissions", new ArrayList<String>());
|
thisGroupNode.put("permissions", new ArrayList<String>());
|
||||||
}
|
|
||||||
if (thisGroupNode.get("permissions") instanceof List) {
|
|
||||||
for (Object o : ((List) thisGroupNode.get("permissions"))) {
|
|
||||||
try {
|
|
||||||
thisGrp.addPermission(o.toString());
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
// Ignore this entry as it's null.
|
|
||||||
//throw new IllegalArgumentException("Invalid permission node in group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (thisGroupNode.get("permissions") instanceof String) {
|
|
||||||
thisGrp.addPermission((String) thisGroupNode.get("permissions"));
|
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>) for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
if (thisGroupNode.get("permissions") instanceof List) {
|
||||||
|
for (Object o : ((List) thisGroupNode.get("permissions"))) {
|
||||||
|
try {
|
||||||
|
thisGrp.addPermission(o.toString());
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// Ignore this entry as it's null.
|
||||||
|
//throw new IllegalArgumentException("Invalid permission node in group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (thisGroupNode.get("permissions") instanceof String) {
|
||||||
|
thisGrp.addPermission((String) thisGroupNode.get("permissions"));
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>) for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
||||||
|
}
|
||||||
|
thisGrp.sortPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
//INFO NODE
|
//INFO NODE
|
||||||
@ -581,18 +583,20 @@ public class WorldDataHolder {
|
|||||||
}
|
}
|
||||||
if (thisUserNode.get("permissions") == null) {
|
if (thisUserNode.get("permissions") == null) {
|
||||||
thisUserNode.put("permissions", new ArrayList<String>());
|
thisUserNode.put("permissions", new ArrayList<String>());
|
||||||
}
|
} else {
|
||||||
if (thisUserNode.get("permissions") instanceof List) {
|
if (thisUserNode.get("permissions") instanceof List) {
|
||||||
for (Object o : ((List) thisUserNode.get("permissions"))) {
|
for (Object o : ((List) thisUserNode.get("permissions"))) {
|
||||||
thisUser.addPermission(o.toString());
|
thisUser.addPermission(o.toString());
|
||||||
}
|
}
|
||||||
} else if (thisUserNode.get("permissions") instanceof String) {
|
} else if (thisUserNode.get("permissions") instanceof String) {
|
||||||
try {
|
try {
|
||||||
thisUser.addPermission(thisUserNode.get("permissions").toString());
|
thisUser.addPermission(thisUserNode.get("permissions").toString());
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// Ignore this entry as it's null.
|
// Ignore this entry as it's null.
|
||||||
//throw new IllegalArgumentException("Invalid permission node for user: " + thisUser.getName() + " in file: " + UserFile.getPath());
|
//throw new IllegalArgumentException("Invalid permission node for user: " + thisUser.getName() + " in file: " + UserFile.getPath());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
thisUser.sortPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
//SUBGROUPS LOADING
|
//SUBGROUPS LOADING
|
||||||
|
@ -153,15 +153,23 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
private Set<String> populatePerms (List<String> perms, boolean includeChildren) {
|
private Set<String> populatePerms (List<String> perms, boolean includeChildren) {
|
||||||
|
|
||||||
Set<String> permArray = new HashSet<String>();
|
Set<String> permArray = new HashSet<String>();
|
||||||
|
Boolean allPerms = false;
|
||||||
|
|
||||||
// Allow * node to populate ALL perms in Bukkit.
|
// Allow * node to populate ALL permissions to Bukkit.
|
||||||
if (perms.contains("*")) {
|
if (perms.contains("*")) {
|
||||||
permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
|
permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
|
||||||
|
allPerms = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String perm : perms) {
|
for (String perm : perms) {
|
||||||
|
|
||||||
if (!perm.equalsIgnoreCase("*")) {
|
if (!perm.equalsIgnoreCase("*")) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* all permission sets are passed here pre-sorted, alphabetically.
|
||||||
|
* This means negated nodes will be processed before all permissions
|
||||||
|
* other than *.
|
||||||
|
*/
|
||||||
boolean negated = false;
|
boolean negated = false;
|
||||||
if (perm.startsWith("-"))
|
if (perm.startsWith("-"))
|
||||||
negated = true;
|
negated = true;
|
||||||
@ -172,12 +180,17 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
if ((negated) && (permArray.contains(perm.substring(1))))
|
if ((negated) && (permArray.contains(perm.substring(1))))
|
||||||
permArray.remove(perm.substring(1));
|
permArray.remove(perm.substring(1));
|
||||||
|
|
||||||
if (includeChildren) {
|
/**
|
||||||
|
* Process child nodes if required,
|
||||||
|
* or this is a negated node AND we used * to include all permissions,
|
||||||
|
* in which case we need to remove all children of that node.
|
||||||
|
*/
|
||||||
|
if ((includeChildren) || (negated && allPerms)) {
|
||||||
|
|
||||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren((negated ? perm.substring(1) : perm), new HashSet<String>());
|
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren((negated ? perm.substring(1) : perm), new HashSet<String>());
|
||||||
|
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
if (negated) {
|
if (negated || (negated && allPerms)) {
|
||||||
|
|
||||||
// Remove children of negated nodes
|
// Remove children of negated nodes
|
||||||
for (String child : children.keySet())
|
for (String child : children.keySet())
|
||||||
@ -185,7 +198,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
if (permArray.contains(child))
|
if (permArray.contains(child))
|
||||||
permArray.remove(child);
|
permArray.remove(child);
|
||||||
|
|
||||||
} else {
|
} else if (!negated){
|
||||||
|
|
||||||
// Add child nodes
|
// Add child nodes
|
||||||
for (String child : children.keySet())
|
for (String child : children.keySet())
|
||||||
|
Loading…
Reference in New Issue
Block a user