geforkt von Mirrors/FastAsyncWorldEdit
Synchronise access to the PriorityQueue used for effect queuing in AbstractWorld
- Makes it thread-safe
Dieser Commit ist enthalten in:
Ursprung
0ccae19ded
Commit
d3696f91d4
@ -111,6 +111,8 @@ public abstract class AbstractWorld implements World {
|
|||||||
public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
|
public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
|
||||||
if (taskId == -1) {
|
if (taskId == -1) {
|
||||||
taskId = server.schedule(0, 1, () -> {
|
taskId = server.schedule(0, 1, () -> {
|
||||||
|
//FAWE start - access to PriorityQueue is not thread-safe
|
||||||
|
synchronized (effectQueue) {
|
||||||
int max = Math.max(1, Math.min(30, effectQueue.size() / 3));
|
int max = Math.max(1, Math.min(30, effectQueue.size() / 3));
|
||||||
for (int i = 0; i < max; ++i) {
|
for (int i = 0; i < max; ++i) {
|
||||||
if (effectQueue.isEmpty()) {
|
if (effectQueue.isEmpty()) {
|
||||||
@ -119,6 +121,8 @@ public abstract class AbstractWorld implements World {
|
|||||||
|
|
||||||
effectQueue.poll().play();
|
effectQueue.poll().play();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//FAWE end
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +130,11 @@ public abstract class AbstractWorld implements World {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FAWE start - access to PriorityQueue is not thread-safe
|
||||||
|
synchronized (effectQueue) {
|
||||||
effectQueue.offer(new QueuedEffect(position.toVector3(), blockType, priority));
|
effectQueue.offer(new QueuedEffect(position.toVector3(), blockType, priority));
|
||||||
|
}
|
||||||
|
//FAWE end
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren