summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2011-09-26 22:54:34 +0100
committerKHobbits <rob@khobbits.co.uk>2011-09-26 22:54:34 +0100
commit0bf6ef5c58ec496fb2a54e937fb1bca37bb42415 (patch)
tree7d5c656402e391dd1ae2e11b815bd282d25d2d27
parent223ae8c87b189c542f9f797c39df5d27a84912f0 (diff)
parent7ce7d9b8eacbb52d338f0c6485296ad8e5535b0e (diff)
downloadEssentials-0bf6ef5c58ec496fb2a54e937fb1bca37bb42415.tar
Essentials-0bf6ef5c58ec496fb2a54e937fb1bca37bb42415.tar.gz
Essentials-0bf6ef5c58ec496fb2a54e937fb1bca37bb42415.tar.lz
Essentials-0bf6ef5c58ec496fb2a54e937fb1bca37bb42415.tar.xz
Essentials-0bf6ef5c58ec496fb2a54e937fb1bca37bb42415.zip
Merge remote branch 'remotes/ess/groupmanager' into essmaster
-rw-r--r--EssentialsGroupManager/src/Changelog.txt4
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java71
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java25
3 files changed, 16 insertions, 84 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index cded4ceb8..ee7c77a23 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -19,4 +19,6 @@ v 1.1:
- manulistp now accepts an additional + to list ALL Superperms effective permissions (/manulistp <name> +).
- 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. \ No newline at end of file
+ - Added a BukkitPermsUpdateTask to only update superperms once on a load/reload.
+ - 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
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index 1c2aa8fb7..affa72c78 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -16,8 +16,6 @@
package org.anjocaido.groupmanager.permissions;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -28,7 +26,6 @@ import java.util.Set;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.User;
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
-import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -134,15 +131,10 @@ public class BukkitPermissions {
}
// find matching permissions
- PermissionCheckResult permissionResult;
Boolean value;
for (Permission permission : registeredPermissions) {
- permissionResult = worldData.getPermissionsHandler().checkFullUserPermission(user, permission.getName());
- if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND))
- value = true;
- else
- value = false;
-
+ value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
+
attachment.setPermission(permission, value);
}
@@ -161,19 +153,6 @@ public class BukkitPermissions {
}
}
player.recalculatePermissions();
-
- /*
- // List perms for this player
- GroupManager.logger.info("Attachment Permissions:");
- for(Map.Entry<String, Boolean> entry : attachment.getPermissions().entrySet()){
- GroupManager.logger.info(" " + entry.getKey() + " = " + entry.getValue());
- }
-
- GroupManager.logger.info("Effective Permissions:");
- for(PermissionAttachmentInfo info : player.getEffectivePermissions()){
- GroupManager.logger.info(" " + info.getPermission() + " = " + info.getValue());
- }
- */
}
public List<String> listPerms(Player player) {