From a7b29ab82f569e4a9312e790eaf700f38ac252ef Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 15 Jan 2017 22:15:22 +1100 Subject: [PATCH] Tweak some stuff --- .../fawe/bukkit/v1_11/BukkitQueue_1_11.java | 4 +-- .../boydti/fawe/logging/LoggingChangeSet.java | 4 --- .../changeset/AbstractDelegateChangeSet.java | 30 +++++++++---------- .../fawe/object/changeset/FaweChangeSet.java | 28 ++++++++--------- 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java index b9e17bdd..36527757 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java @@ -88,7 +88,7 @@ public class BukkitQueue_1_11 extends BukkitQueue_0> 4).fromLegacyData(i & 0xF); } catch (Throwable ignore) {} diff --git a/core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java b/core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java index ce8cba1c..c7e7ce36 100644 --- a/core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java +++ b/core/src/main/java/com/boydti/fawe/logging/LoggingChangeSet.java @@ -13,10 +13,6 @@ import org.primesoft.blockshub.api.IWorld; public class LoggingChangeSet extends AbstractDelegateChangeSet { - public static void main(String[] args) { - - } - private static boolean initialized = false; public static FaweChangeSet wrap(FawePlayer player, FaweChangeSet parent) { diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java b/core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java index ede6ff8d..813797bd 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java @@ -22,6 +22,21 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { this.parent = parent; } + @Override + public void addChangeTask(FaweQueue queue) { + super.addChangeTask(queue); + } + + @Override + public boolean flushAsync() { + return super.flushAsync(); + } + + @Override + public boolean flush() { + return super.flush() && parent.flush(); + } + public final FaweChangeSet getParent() { return parent; } @@ -36,16 +51,6 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { return parent.getWorld(); } - @Override - public boolean flushAsync() { - return parent.flushAsync(); - } - - @Override - public boolean flush() { - return parent.flush(); - } - @Override public void add(int x, int y, int z, int combinedFrom, int combinedTo) { parent.add(x, y, z, combinedFrom, combinedTo); @@ -145,9 +150,4 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { public void add(int x, int y, int z, int combinedFrom, BaseBlock to) { parent.add(x, y, z, combinedFrom, to); } - - @Override - public void addChangeTask(FaweQueue queue) { - parent.addChangeTask(queue); - } } diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java b/core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java index 1922d589..23627f4c 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/FaweChangeSet.java @@ -35,10 +35,8 @@ public abstract class FaweChangeSet implements ChangeSet { private final String worldName; private final boolean mainThread; private final int layers; - protected final AtomicInteger waitingCombined = new AtomicInteger(0); - private final AtomicInteger waitingAsync = new AtomicInteger(0); -// private Object lockCombined = new Object(); -// private Object lockAsync = new Object(); + protected AtomicInteger waitingCombined = new AtomicInteger(0); + protected AtomicInteger waitingAsync = new AtomicInteger(0); public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) { if (Settings.IMP.HISTORY.USE_DISK) { @@ -220,7 +218,7 @@ public abstract class FaweChangeSet implements ChangeSet { queue.setChangeTask(new RunnableVal2() { @Override public void run(final FaweChunk previous, final FaweChunk next) { - waitingCombined.incrementAndGet(); + FaweChangeSet.this.waitingCombined.incrementAndGet(); Runnable run = new Runnable() { @Override public void run() { @@ -263,7 +261,7 @@ public abstract class FaweChangeSet implements ChangeSet { default: char combinedIdPrevious = previousLayer != null ? previousLayer[index] : 0; if (combinedIdCurrent != combinedIdPrevious) { - synchronized (this) { + synchronized (FaweChangeSet.this) { add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent); } } @@ -277,14 +275,14 @@ public abstract class FaweChangeSet implements ChangeSet { // Tiles created Map tiles = next.getTiles(); for (Map.Entry entry : tiles.entrySet()) { - synchronized (this) { + synchronized (FaweChangeSet.this) { addTileCreate(entry.getValue()); } } // Tiles removed tiles = previous.getTiles(); for (Map.Entry entry : tiles.entrySet()) { - synchronized (this) { + synchronized (FaweChangeSet.this) { addTileRemove(entry.getValue()); } } @@ -294,14 +292,14 @@ public abstract class FaweChangeSet implements ChangeSet { // Entities created Set entities = next.getEntities(); for (CompoundTag entityTag : entities) { - synchronized (this) { + synchronized (FaweChangeSet.this) { addEntityCreate(entityTag); } } // Entities removed entities = previous.getEntities(); for (CompoundTag entityTag : entities) { - synchronized (this) { + synchronized (FaweChangeSet.this) { addEntityRemove(entityTag); } } @@ -309,12 +307,12 @@ public abstract class FaweChangeSet implements ChangeSet { } catch (Throwable e) { MainUtil.handleError(e); } finally { - if (waitingCombined.decrementAndGet() <= 0) { - synchronized (waitingAsync) { - waitingAsync.notifyAll(); + if (FaweChangeSet.this.waitingCombined.decrementAndGet() <= 0) { + synchronized (FaweChangeSet.this.waitingAsync) { + FaweChangeSet.this.waitingAsync.notifyAll(); } - synchronized (waitingCombined) { - waitingCombined.notifyAll(); + synchronized (FaweChangeSet.this.waitingCombined) { + FaweChangeSet.this.waitingCombined.notifyAll(); } } }