mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Synchronize pushing to Bukkit perms to prevent any
ConcurrentModificationException.
This commit is contained in:
parent
999d922fb9
commit
b860e943f6
2 changed files with 22 additions and 18 deletions
|
@ -205,4 +205,5 @@ v 2.0:
|
|||
- Add support for Rcon.
|
||||
- Prevent GM commands from being used on CommandBlocks.
|
||||
- Clear our attachment map upon a manload so we correctly reconfigure a players new permissions.
|
||||
- Synchronize the raising of GroupManager events to Bukkit.getServer() (should prevent deadlocks).
|
||||
- Synchronize the raising of GroupManager events to Bukkit.getServer() (should prevent deadlocks).
|
||||
- Synchronize pushing to Bukkit perms to prevent any ConcurrentModificationException.
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue