summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt8
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java56
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java21
3 files changed, 54 insertions, 31 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 41b5613af..c3dce16d9 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -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.
- do not allow inherited permissions to negate higher perms.
- Fixed a bug when pushing superperms in the wrong order.
- - Fix players retaining permissions when demoted. \ No newline at end of file
+ - 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 \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index 3cbfbd50b..4fe1daaa5 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -451,7 +451,7 @@ public class WorldDataHolder {
Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
Group thisGrp = ph.createGroup(groupKey);
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) {
thisGroupNode.put("default", false);
@@ -467,20 +467,22 @@ public class WorldDataHolder {
//PERMISSIONS NODE
if (thisGroupNode.get("permissions") == null) {
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 {
- 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
@@ -581,18 +583,20 @@ public class WorldDataHolder {
}
if (thisUserNode.get("permissions") == null) {
thisUserNode.put("permissions", new ArrayList<String>());
- }
- if (thisUserNode.get("permissions") instanceof List) {
- for (Object o : ((List) thisUserNode.get("permissions"))) {
- thisUser.addPermission(o.toString());
- }
- } else if (thisUserNode.get("permissions") instanceof String) {
- try {
- thisUser.addPermission(thisUserNode.get("permissions").toString());
- } catch (NullPointerException e) {
- // Ignore this entry as it's null.
- //throw new IllegalArgumentException("Invalid permission node for user: " + thisUser.getName() + " in file: " + UserFile.getPath());
- }
+ } else {
+ if (thisUserNode.get("permissions") instanceof List) {
+ for (Object o : ((List) thisUserNode.get("permissions"))) {
+ thisUser.addPermission(o.toString());
+ }
+ } else if (thisUserNode.get("permissions") instanceof String) {
+ try {
+ thisUser.addPermission(thisUserNode.get("permissions").toString());
+ } catch (NullPointerException e) {
+ // Ignore this entry as it's null.
+ //throw new IllegalArgumentException("Invalid permission node for user: " + thisUser.getName() + " in file: " + UserFile.getPath());
+ }
+ }
+ thisUser.sortPermissions();
}
//SUBGROUPS LOADING
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index 2e008e223..7436bec70 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -153,15 +153,23 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
private Set<String> populatePerms (List<String> perms, boolean includeChildren) {
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("*")) {
permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
+ allPerms = true;
}
for (String perm : perms) {
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;
if (perm.startsWith("-"))
negated = true;
@@ -172,12 +180,17 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if ((negated) && (permArray.contains(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>());
if (children != null) {
- if (negated) {
+ if (negated || (negated && allPerms)) {
// Remove children of negated nodes
for (String child : children.keySet())
@@ -185,7 +198,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if (permArray.contains(child))
permArray.remove(child);
- } else {
+ } else if (!negated){
// Add child nodes
for (String child : children.keySet())