From d1312c66e1d3556cef039e5895e959842f733c0a Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sat, 20 Oct 2018 19:54:13 -0700 Subject: [PATCH] Ensure we flush iff it is needed --- .../main/java/com/sk89q/worldedit/EditSession.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index aa630bfa1..bc98a20e3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -415,7 +415,7 @@ public class EditSession implements Extent, AutoCloseable { } return; } - if (!batchingChunks) { + if (!batchingChunks && isBatchingChunks()) { flushSession(); } chunkBatchingExtent.setEnabled(batchingChunks); @@ -428,9 +428,15 @@ public class EditSession implements Extent, AutoCloseable { * @see #setBatchingChunks(boolean) */ public void disableBuffering() { - // We optimize here to avoid double calls to flushSession. + // We optimize here to avoid repeated calls to flushSession. + boolean needsFlush = isQueueEnabled() || isBatchingChunks(); + if (needsFlush) { + flushSession(); + } reorderExtent.setEnabled(false); - setBatchingChunks(false); + if (chunkBatchingExtent != null) { + chunkBatchingExtent.setEnabled(false); + } } /**