diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index 957c402b..c345dacd 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -121,9 +121,19 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue } public void changeWorld(World world, FaweQueue queue) { - flush(); this.parent = world; - this.queue = queue; + if (queue != this.queue) { + if (this.queue != null) { + final FaweQueue oldQueue = this.queue; + TaskManager.IMP.async(new Runnable() { + @Override + public void run() { + oldQueue.flush(); + } + }); + } + this.queue = queue; + } setParent(queue); } diff --git a/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java b/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java index d4b6b8e8..17e52228 100644 --- a/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java +++ b/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java @@ -196,7 +196,7 @@ public class NMSRelighter implements Relighter{ Map currentMap = lightQueue.get(index); if (currentMap == null) { currentMap = new Int2ObjectOpenHashMap<>(); - synchronized (lightQueue) { + synchronized (this) { this.lightQueue.put(index, currentMap); } } diff --git a/core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java b/core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java index f03fa23d..45e48644 100644 --- a/core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java +++ b/core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java @@ -33,7 +33,7 @@ public class WeakFaweQueueMap implements IFaweQueueMap { public Reference put(long key, Reference value) { if (parent.getProgressTask() != null) { try { - parent.getProgressTask().run(FaweQueue.ProgressType.QUEUE, size() + 1); + parent.getProgressTask().run(FaweQueue.ProgressType.QUEUE, size()); } catch (Throwable e) { e.printStackTrace(); }