summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java71
2 files changed, 13 insertions, 61 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 0eac3c14c..ee7c77a23 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -20,4 +20,5 @@ v 1.1:
- manucheckp also outputs superperms results.
- Removed superperms update on plugins unloading. Unneeded and created undesired lag on shutdown.
- Added a BukkitPermsUpdateTask to only update superperms once on a load/reload.
- - Fix for GM not checking inheritance for known superperms nodes. \ No newline at end of file
+ - Fix for GM not checking inheritance for known superperms nodes.
+ - Optimized getAllPlayersPermissions and fixed pushing unknown perms to superperms. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index 5830f0c88..cb9fdf628 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -81,73 +81,24 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
}
/**
- * Returns All permissions (including inheritance) of player name.
+ * Returns All permissions (including inheritance and sub groups) for the player.
+ *
* @param userName
* @return
*/
@Override
public List<String> getAllPlayersPermissions(String userName) {
- User user = ph.getUser(userName);
- List<String> playerPermArray = new ArrayList<String>(user.getPermissionList());
- List<String> playerMainGroupPermArray = new ArrayList<String>(user.getGroup().getPermissionList());
- List<String> subGroupsPermArray = new ArrayList<String>();
- List<String> returnPermArray = new ArrayList<String>();
+ List<String> playerPermArray = new ArrayList<String>(ph.getUser(userName).getPermissionList());
- for (String subGroup : user.subGroupListStringCopy()) {
- subGroupsPermArray.addAll(ph.getGroup(subGroup).getPermissionList());
+ for (String group : getGroups(userName)) {
+ for (String perm : ph.getGroup(group).getPermissionList()) {
+ if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-"+perm)))
+ playerPermArray.add(perm);
+ }
}
-
- for (String permission : subGroupsPermArray) {
- /*
- * Add each Negated permission
- * unless it's being overridden by a higher permission
- */
- if (permission.startsWith("-")
- && !playerMainGroupPermArray.contains(permission.substring(1))
- && !playerPermArray.contains(permission.substring(1))
- && !playerMainGroupPermArray.contains("*")
- && !playerPermArray.contains("*")) {
- if (!returnPermArray.contains(permission)) {
- returnPermArray.add(permission);
- }
- } else
- if (!returnPermArray.contains(permission)
- && !playerMainGroupPermArray.contains("-"+permission)
- && !playerPermArray.contains("-"+permission)) {
- returnPermArray.add(permission);
- }
- }
-
- for (String permission : playerMainGroupPermArray) {
- /*
- * Add each Negated permission
- * unless it's being overridden by a higher permission
- */
- if (permission.startsWith("-")
- && !playerPermArray.contains(permission.substring(1))
- && !playerMainGroupPermArray.contains("*")
- && !playerPermArray.contains("*")) {
- if (!returnPermArray.contains(permission)) {
- returnPermArray.add(permission);
- }
- } else
- if (!returnPermArray.contains(permission)
- && !playerPermArray.contains("-"+permission)) {
- returnPermArray.add(permission);
- }
- }
-
- for (String permission : playerPermArray) {
- /*
- * Add each permission
- */
- if (!returnPermArray.contains(permission)) {
- returnPermArray.add(permission);
- }
- }
-
- return returnPermArray;
+
+ return playerPermArray;
}
/**
@@ -159,7 +110,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
* And verify the player 'MyAdmin', which is Admin, it will return true for both
* Admin or Moderator groups.
*
- * Mas if you haave a player 'MyModerator', which is Moderator,
+ * Mas if you have a player 'MyModerator', which is Moderator,
* it will give false if you pass Admin in group parameter.
*
* @param name