summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-09-25 22:21:15 +0100
committerKHobbits <rob@khobbits.co.uk>2012-09-25 22:21:15 +0100
commit765e849b0fdc7603e56c806acd464d8f5dde1ff4 (patch)
tree7f9498bc946b9b3a7487a1d86619828c89dc0ca8
parent50591c8fd829725a05f724099d38b55ddfc106f4 (diff)
downloadEssentials-765e849b0fdc7603e56c806acd464d8f5dde1ff4.tar
Essentials-765e849b0fdc7603e56c806acd464d8f5dde1ff4.tar.gz
Essentials-765e849b0fdc7603e56c806acd464d8f5dde1ff4.tar.lz
Essentials-765e849b0fdc7603e56c806acd464d8f5dde1ff4.tar.xz
Essentials-765e849b0fdc7603e56c806acd464d8f5dde1ff4.zip
Handle negated wildcard perms in generic superperms
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java33
1 files changed, 15 insertions, 18 deletions
diff --git a/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java
index 5dbe9eb93..0b4b93058 100644
--- a/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java
+++ b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java
@@ -31,29 +31,26 @@ public class SuperpermsHandler implements IPermissionsHandler
}
@Override
- public boolean hasPermission(final Player base, final String node)
+ public boolean hasPermission(final Player base, String node)
{
- if (base.hasPermission("*"))
+ String permCheck = node;
+ int index;
+ while (true)
{
- return true;
- }
- if (base.hasPermission("-" + node))
- {
- return false;
- }
- final String[] parts = node.split("\\.");
- final StringBuilder builder = new StringBuilder(node.length());
- for (String part : parts)
- {
- builder.append('*');
- if (base.hasPermission(builder.toString()))
+ if (base.isPermissionSet(permCheck))
{
- return true;
+ return base.hasPermission(permCheck);
}
- builder.deleteCharAt(builder.length() - 1);
- builder.append(part).append('.');
+
+ index = node.lastIndexOf('.');
+ if (index < 1)
+ {
+ return base.hasPermission("*");
+ }
+
+ node = node.substring(0, index);
+ permCheck = node + ".*";
}
- return base.hasPermission(node);
}
@Override