summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2011-09-06 10:11:21 +0100
committerElgarL <ElgarL@palmergames.com>2011-09-06 10:11:21 +0100
commit0654a76ccc64b62549ef8f9389b145a2e9a602a4 (patch)
tree3743855371efd382e0a7371ccd75e1a27968836d
parentaa085de3e78fe09452f815aa92f6c06783fa06bd (diff)
downloadEssentials-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.
-rw-r--r--EssentialsGroupManager/src/Changelog.txt4
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java40
2 files changed, 36 insertions, 8 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 7005c8cc1..56f52a998 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -8,4 +8,6 @@ v 1.1:
- Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead.
- Fix for Users.yml containing only 'users:' causing a crash.
- GroupManager will now generate a fresh Users and Groups yml if either file is empty.
- - Fix for an infinite loop bug with the new Bukkit Perms during a new user creation. \ No newline at end of file
+ - Fix for an infinite loop bug with the new Bukkit Perms during a new user creation.
+v 1.2:
+ - Fixed BukkitPerms population. Wasn't correctly setting superperms. \ No newline at end of file
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() {