diff options
author | ElgarL <ElgarL@palmergames.com> | 2011-09-06 10:11:21 +0100 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2011-09-06 10:11:21 +0100 |
commit | 0654a76ccc64b62549ef8f9389b145a2e9a602a4 (patch) | |
tree | 3743855371efd382e0a7371ccd75e1a27968836d /EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions | |
parent | aa085de3e78fe09452f815aa92f6c06783fa06bd (diff) | |
download | Essentials-0654a76ccc64b62549ef8f9389b145a2e9a602a4.tar Essentials-0654a76ccc64b62549ef8f9389b145a2e9a602a4.tar.gz Essentials-0654a76ccc64b62549ef8f9389b145a2e9a602a4.tar.lz Essentials-0654a76ccc64b62549ef8f9389b145a2e9a602a4.tar.xz Essentials-0654a76ccc64b62549ef8f9389b145a2e9a602a4.zip |
- Fixed BukkitPerms population. Wasn't correctly setting superperms.
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 5df263eb4..383020a7c 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -16,8 +16,10 @@ package org.anjocaido.groupmanager.permissions;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -39,6 +41,7 @@ import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
+import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -115,22 +118,45 @@ public class BukkitPermissions { PermissionAttachment attachment = this.attachments.get(player);
User user = GroupManager.getWorldsHolder().getWorldData(world).getUser(player.getName());
-
+ List<String> permissions = user.getPermissionList();
+
// clear permissions
for (String permission : attachment.getPermissions().keySet()) {
attachment.unsetPermission(permission);
- }
-
+ }
+
+ // find matching permissions
for (Permission permission : registeredPermissions) {
boolean permissionValue = user.getGroup().hasSamePermissionNode(permission.getName());
-
- //GroupManager.logger.info(permission.getName() + " : " + Boolean.toString(permissionValue));
-
attachment.setPermission(permission, permissionValue);
- }
+ }
+
+ // all permissions
+ for (String permission : permissions) {
+ Boolean value = true;
+ if (permission.startsWith("-")) {
+ permission = permission.substring(1); // cut off -
+ value = false;
+ }
+ if (!attachment.getPermissions().containsKey(permission)) {
+ attachment.setPermission(permission, value);
+ }
+ }
+
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 void updateAllPlayers() {
|