- Fixed BukkitPerms population. Wasn't correctly setting superperms.

This commit is contained in:
ElgarL 2011-09-06 10:11:21 +01:00
parent aa085de3e7
commit 0654a76ccc
2 changed files with 36 additions and 8 deletions

View File

@ -9,3 +9,5 @@ v 1.1:
- Fix for Users.yml containing only 'users:' causing a crash. - 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. - 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. - 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.

View File

@ -16,8 +16,10 @@
package org.anjocaido.groupmanager.permissions; package org.anjocaido.groupmanager.permissions;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -39,6 +41,7 @@ import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener; import org.bukkit.event.server.ServerListener;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -115,22 +118,45 @@ public class BukkitPermissions {
PermissionAttachment attachment = this.attachments.get(player); PermissionAttachment attachment = this.attachments.get(player);
User user = GroupManager.getWorldsHolder().getWorldData(world).getUser(player.getName()); User user = GroupManager.getWorldsHolder().getWorldData(world).getUser(player.getName());
List<String> permissions = user.getPermissionList();
// clear permissions // clear permissions
for (String permission : attachment.getPermissions().keySet()) { for (String permission : attachment.getPermissions().keySet()) {
attachment.unsetPermission(permission); attachment.unsetPermission(permission);
} }
// find matching permissions
for (Permission permission : registeredPermissions) { for (Permission permission : registeredPermissions) {
boolean permissionValue = user.getGroup().hasSamePermissionNode(permission.getName()); boolean permissionValue = user.getGroup().hasSamePermissionNode(permission.getName());
//GroupManager.logger.info(permission.getName() + " : " + Boolean.toString(permissionValue));
attachment.setPermission(permission, permissionValue); attachment.setPermission(permission, permissionValue);
} }
player.recalculatePermissions(); // 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() { public void updateAllPlayers() {