diff options
author | ElgarL <ElgarL@palmergames.com> | 2013-01-13 16:20:09 +0000 |
---|---|---|
committer | ElgarL <ElgarL@palmergames.com> | 2013-01-13 16:20:09 +0000 |
commit | 2731674c85b72c3d76dbc7f677fc8e7cd9884f53 (patch) | |
tree | 570e66838eb17a23a143971fb670ad0f8f4776e3 /EssentialsGroupManager/src/org | |
parent | 14ceb5ccc96f44c87bc18a6a60116643cc5b76c6 (diff) | |
download | Essentials-2731674c85b72c3d76dbc7f677fc8e7cd9884f53.tar Essentials-2731674c85b72c3d76dbc7f677fc8e7cd9884f53.tar.gz Essentials-2731674c85b72c3d76dbc7f677fc8e7cd9884f53.tar.lz Essentials-2731674c85b72c3d76dbc7f677fc8e7cd9884f53.tar.xz Essentials-2731674c85b72c3d76dbc7f677fc8e7cd9884f53.zip |
Synchronize pushing to Bukkit perms to prevent any
ConcurrentModificationException.
Diffstat (limited to 'EssentialsGroupManager/src/org')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 6b02a2286..a200a7b9a 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -137,8 +137,7 @@ public class BukkitPermissions { /**
* Push all permissions which are registered with GM for this player, on
- * this world to Bukkit
- * and make it update for the child nodes.
+ * this world to Bukkit and make it update for the child nodes.
*
* @param player
* @param world
@@ -148,9 +147,9 @@ public class BukkitPermissions { if (player == null || !GroupManager.isLoaded()) {
return;
}
-
+
String name = player.getName();
-
+
// Reset the User objects player reference.
User user = plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(name);
if (user != null)
@@ -175,7 +174,8 @@ public class BukkitPermissions { List<String> playerPermArray = new ArrayList<String>(plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getAllPlayersPermissions(name, false));
LinkedHashMap<String, Boolean> newPerms = new LinkedHashMap<String, Boolean>();
- // Sort the perm list by parent/child, so it will push to superperms correctly.
+ // Sort the perm list by parent/child, so it will push to superperms
+ // correctly.
playerPermArray = sort(playerPermArray);
Boolean value = false;
@@ -186,25 +186,28 @@ public class BukkitPermissions { /**
* This is put in place until such a time as Bukkit pull 466 is
- * implemented
- * https://github.com/Bukkit/Bukkit/pull/466
+ * implemented https://github.com/Bukkit/Bukkit/pull/466
*/
try { // Codename_B source
- @SuppressWarnings("unchecked")
- Map<String, Boolean> orig = (Map<String, Boolean>) permissions.get(attachment);
- // Clear the map (faster than removing the attachment and recalculating)
- orig.clear();
- // Then whack our map into there
- orig.putAll(newPerms);
- // That's all folks!
- attachment.getPermissible().recalculatePermissions();
- //player.recalculatePermissions();
+ synchronized (attachment.getPermissible()) {
+
+ @SuppressWarnings("unchecked")
+ Map<String, Boolean> orig = (Map<String, Boolean>) permissions.get(attachment);
+ // Clear the map (faster than removing the attachment and
+ // recalculating)
+ orig.clear();
+ // Then whack our map into there
+ orig.putAll(newPerms);
+ // That's all folks!
+ attachment.getPermissible().recalculatePermissions();
+
+ }
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
-
+
GroupManager.logger.finest("Attachment updated for: " + name);
}
|