diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java index 274288d7..1f2886ba 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java @@ -62,12 +62,12 @@ public class ChunkListener implements Listener { lastX = cx; lastZ = cz; long pair = MathMan.pairInt(cx, cz); - lastCount = counter.get(pair); - if (lastCount == null) { - lastCount = new IntegerTrio(); - counter.put(pair, lastCount); + IntegerTrio tmp = lastCount = counter.get(pair); + if (tmp == null) { + lastCount = tmp = new IntegerTrio(); + counter.put(pair, tmp); } - return lastCount; + return tmp; } public void cleanup(Chunk chunk) { diff --git a/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java b/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java index d3e3c649..c27378bc 100644 --- a/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java +++ b/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java @@ -81,8 +81,8 @@ public class RollbackOptimizedHistory extends DiskStorageHistory { } @Override - public boolean flush() { - if (super.flush()) { + public boolean close() { + if (super.close()) { // Save to DB RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld()); db.logEdit(this); diff --git a/core/src/main/java/com/boydti/fawe/object/NullChangeSet.java b/core/src/main/java/com/boydti/fawe/object/NullChangeSet.java index 44afb47d..31bc342a 100644 --- a/core/src/main/java/com/boydti/fawe/object/NullChangeSet.java +++ b/core/src/main/java/com/boydti/fawe/object/NullChangeSet.java @@ -19,7 +19,7 @@ public class NullChangeSet extends FaweChangeSet { } @Override - public final boolean flush() { + public final boolean close() { return false; } 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 43794735..e600ece5 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 @@ -29,13 +29,13 @@ public class AbstractDelegateChangeSet extends FaweChangeSet { } @Override - public boolean flushAsync() { - return super.flushAsync(); + public boolean closeAsync() { + return super.closeAsync(); } @Override - public boolean flush() { - return super.flush() && parent.flush(); + public boolean close() { + return super.close() && parent.close(); } public final FaweChangeSet getParent() { diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/CPUOptimizedChangeSet.java b/core/src/main/java/com/boydti/fawe/object/changeset/CPUOptimizedChangeSet.java index 599bfc75..222d2914 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/CPUOptimizedChangeSet.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/CPUOptimizedChangeSet.java @@ -95,7 +95,7 @@ public class CPUOptimizedChangeSet extends FaweChangeSet { @Override public boolean isEmpty() { if (changes.isEmpty()) { - flush(); + close(); return changes.isEmpty(); } else { return false; diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java b/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java index ca23dfcf..a9827528 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java @@ -168,6 +168,25 @@ public class DiskStorageHistory extends FaweStreamChangeSet { @Override public boolean flush() { super.flush(); + synchronized (this) { + boolean flushed = osBD != null || osBIO != null || osNBTF != null || osNBTT != null && osENTCF != null || osENTCT != null; + try { + if (osBD != null) osBD.flush(); + if (osBIO != null) osBIO.flush(); + if (osNBTF != null) osNBTF.flush(); + if (osNBTT != null) osNBTT.flush(); + if (osENTCF != null) osENTCF.flush(); + if (osENTCT != null) osENTCT.flush(); + } catch (Exception e) { + MainUtil.handleError(e); + } + return flushed; + } + } + + @Override + public boolean close() { + super.close(); synchronized (this) { boolean flushed = osBD != null || osBIO != null || osNBTF != null || osNBTT != null && osENTCF != null || osENTCT != null; try { 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 386ee57c..62f1e0c2 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 @@ -69,7 +69,7 @@ public abstract class FaweChangeSet implements ChangeSet { return world; } - public boolean flushAsync() { + public boolean closeAsync() { waitingAsync.incrementAndGet(); TaskManager.IMP.async(new Runnable() { @Override @@ -78,7 +78,7 @@ public abstract class FaweChangeSet implements ChangeSet { synchronized (waitingAsync) { waitingAsync.notifyAll(); } - flush(); + close(); } }); return true; @@ -104,6 +104,10 @@ public abstract class FaweChangeSet implements ChangeSet { return true; } + public boolean close() { + return flush(); + } + public abstract void add(int x, int y, int z, int combinedFrom, int combinedTo); @Override diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java b/core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java index 6582b3d3..b68ebc38 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java @@ -655,7 +655,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet { } public Iterator getIterator(final boolean dir) { - flush(); + close(); try { final Iterator tileCreate = getTileIterator(getTileCreateIS(), true, dir); final Iterator tileRemove = getTileIterator(getTileRemoveIS(), false, dir); diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java b/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java index 5f3ae1c4..0691ea6f 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java @@ -56,6 +56,25 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { @Override public boolean flush() { super.flush(); + synchronized (this) { + try { + if (idsStream != null) idsStreamZip.flush(); + if (biomeStream != null) biomeStreamZip.flush(); + if (entCStream != null) entCStreamZip.flush(); + if (entRStream != null) entRStreamZip.flush(); + if (tileCStream != null) tileCStreamZip.flush(); + if (tileRStream != null) tileRStreamZip.flush(); + return true; + } catch (IOException e) { + MainUtil.handleError(e); + } + } + return false; + } + + @Override + public boolean close() { + super.close(); synchronized (this) { try { if (idsStream != null) { diff --git a/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java b/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java index 70efe8b3..183dda68 100644 --- a/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java +++ b/core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java @@ -1,7 +1,6 @@ package com.boydti.fawe.object.clipboard; import com.boydti.fawe.object.RunnableVal2; -import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; @@ -49,7 +48,6 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { @Override public void forEach(final RunnableVal2 task, boolean air) { - MainUtil.stacktrace(); Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); final Vector pos = new Vector(); diff --git a/core/src/main/java/com/sk89q/worldedit/EditSession.java b/core/src/main/java/com/sk89q/worldedit/EditSession.java index 3f8193ef..c4550ee5 100644 --- a/core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -585,7 +585,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting public void enableQueue() {} /** - * Disable the queue. This will flush the queue. + * Disable the queue. This will close the queue. */ public void disableQueue() { if (this.isQueueEnabled()) { @@ -1313,9 +1313,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting } if (getChangeSet() != null) { if (Settings.IMP.HISTORY.COMBINE_STAGES) { - ((FaweChangeSet) getChangeSet()).flushAsync(); + ((FaweChangeSet) getChangeSet()).closeAsync(); } else { - ((FaweChangeSet) getChangeSet()).flush(); + ((FaweChangeSet) getChangeSet()).close(); } } } diff --git a/core/src/main/java/com/sk89q/worldedit/LocalSession.java b/core/src/main/java/com/sk89q/worldedit/LocalSession.java index bd0795cd..9877d77e 100644 --- a/core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -430,7 +430,7 @@ public class LocalSession { private FaweChangeSet getChangeSet(Object o) { if (o instanceof FaweChangeSet) { FaweChangeSet cs = (FaweChangeSet) o; - cs.flush(); + cs.close(); return cs; } if (o instanceof Integer) { diff --git a/core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index a0d17dd2..d352b2d6 100644 --- a/core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -234,13 +234,11 @@ public class EllipsoidRegion extends AbstractRegion { return false; } if (sphere) { - System.out.println((cx2 + cy2 + cz2) + " | " + radiusLengthSqr); return cx2 + cy2 + cz2 <= radiusLengthSqr; } double cxd = (double) cx / radius.getBlockX(); double cyd = (double) cy / radius.getBlockY(); double czd = (double) cz / radius.getBlockZ(); - System.out.println((cxd * cxd + cyd * cyd + czd * czd) + " | " + 1); return cxd * cxd + cyd * cyd + czd * czd <= 1; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java index 903ad35f..e312ca98 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java @@ -91,7 +91,7 @@ public class Sniper { } if (tmpQueue != null) { FaweChangeSet changeSet = tmpQueue.getChangeSet(); - changeSet.flushAsync(); + changeSet.closeAsync(); FawePlayer fp = FawePlayer.wrap(getPlayer()); LocalSession session = fp.getSession(); session.remember(changeSet.toEditSession(fp));