Fix TickTask, lighter synchronization.

This commit is contained in:
asofold 2012-09-09 07:25:38 +02:00
parent f9cfd8bd5b
commit ae317f4154

View File

@ -67,10 +67,13 @@ public class TickTask implements Runnable {
}
private void executeActions() {
final List<DelayedActionsExecution> copyActions = new LinkedList<DelayedActionsExecution>();
synchronized (delayedActions) {
for (final DelayedActionsExecution actions : delayedActions){
actions.execute();
copyActions.addAll(delayedActions);
delayedActions.clear();
}
for (final DelayedActionsExecution actions : copyActions){
actions.execute();
}
}
@ -95,8 +98,12 @@ public class TickTask implements Runnable {
* Only call from the main thread!
*/
public static void updatePermissions() {
final List<PermissionUpdateEntry> copyPermissions = new LinkedList<PermissionUpdateEntry>();
synchronized (permissionUpdates) {
for (final PermissionUpdateEntry entry : permissionUpdates){
copyPermissions.addAll(permissionUpdates);
permissionUpdates.clear();
}
for (final PermissionUpdateEntry entry : copyPermissions){
final Player player = Bukkit.getPlayerExact(entry.playerName);
if (player == null || !player.isOnline()) continue;
final String[] perms = entry.checkType.getConfigFactory().getConfig(player).getCachePermissions();
@ -107,8 +114,6 @@ public class TickTask implements Runnable {
}
}
permissionUpdates.clear();
}
}
}