Update to 2.0

Fix GM reporting of permission inheritance to retain the correct order.
Lower inheritance groups can no longer negate a higher groups
permissions.
This commit is contained in:
ElgarL 2012-04-05 12:54:26 +01:00
parent 183602ac28
commit 381886245b
2 changed files with 17 additions and 17 deletions

View File

@ -160,4 +160,6 @@ v 1.9:
- Force remove player attachments on disconnect, and tidyup during player join in case of any errors. Fixes a bug of losing permissions. - Force remove player attachments on disconnect, and tidyup during player join in case of any errors. Fixes a bug of losing permissions.
- Added a new permission node 'groupmanager.op'. This will cause players with this node to be treated as op's when - Added a new permission node 'groupmanager.op'. This will cause players with this node to be treated as op's when
using GroupManager commands (they will still require each commands permission node to use them). using GroupManager commands (they will still require each commands permission node to use them).
- Prevent Null entries in group inheritance from throwing errors. - Prevent Null entries in group inheritance from throwing errors.
v 2.0:
- Fix GM reporting of permission inheritance to retain the correct order. Lower inheritance groups can no longer negate a higher groups permissions.

View File

@ -144,7 +144,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
// Perm doesn't already exists and there is no negation for it // 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) // 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)) if ((!negated && !playerPermArray.contains(perm) && !playerPermArray.contains("-" + perm))
|| (negated && !playerPermArray.contains(perm.substring(1)))) || (negated && !playerPermArray.contains(perm.substring(1)) && !playerPermArray.contains("-" + perm)))
playerPermArray.add(perm); playerPermArray.add(perm);
} }
} }
@ -164,20 +164,17 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if (perms.contains("*")) { if (perms.contains("*")) {
permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren)); permArray.addAll(GroupManager.BukkitPermissions.getAllRegisteredPermissions(includeChildren));
allPerms = true; allPerms = true;
perms.remove("*");
} }
for (String perm : perms) { for (String perm : perms) {
if (!perm.equalsIgnoreCase("*")) {
/** /**
* all permission sets are passed here pre-sorted, alphabetically. * all permission sets are passed here pre-sorted, alphabetically.
* This means negated nodes will be processed before all permissions * This means negated nodes will be processed before all permissions
* other than *. * other than *.
*/ */
boolean negated = false; boolean negated = perm.startsWith("-");
if (perm.startsWith("-"))
negated = true;
if (!permArray.contains(perm)) { if (!permArray.contains(perm)) {
permArray.add(perm); permArray.add(perm);
@ -195,15 +192,16 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
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 || (negated && allPerms)) { if (negated)
if (allPerms) {
// Remove children of negated nodes // Remove children of negated nodes
for (String child : children.keySet()) for (String child : children.keySet())
if (children.get(child)) if (children.get(child))
if (permArray.contains(child)) if (permArray.contains(child))
permArray.remove(child); permArray.remove(child);
} else if (!negated){ } else {
// Add child nodes // Add child nodes
for (String child : children.keySet()) for (String child : children.keySet())
@ -214,7 +212,6 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
} }
} }
} }
}
} }
return permArray; return permArray;
@ -959,7 +956,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
for (String sonName : now.getInherits()) { for (String sonName : now.getInherits()) {
Group son = ph.getGroup(sonName); Group son = ph.getGroup(sonName);
if (son != null && !alreadyVisited.contains(son)) { if (son != null && !alreadyVisited.contains(son)) {
stack.push(son); // Add rather than push to retain inheritance order.
stack.add(son);
alreadyVisited.add(son); alreadyVisited.add(son);
} }
} }