From e202348dac02449f14db7daac5a89f5be2b49aa6 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sat, 3 Nov 2018 22:22:43 -0700 Subject: [PATCH] Simplify commit-required detection --- .../java/com/sk89q/worldedit/EditSession.java | 20 +++++++++---------- .../sk89q/worldedit/TracedEditSession.java | 5 +---- 2 files changed, 10 insertions(+), 15 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 daf542958..094d52327 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -104,7 +104,6 @@ import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -113,8 +112,6 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -234,14 +231,15 @@ public class EditSession implements Extent, AutoCloseable { return event.getExtent(); } - // pkg private for TracedEditSession only - - ChunkBatchingExtent getChunkBatchingExtent() { - return chunkBatchingExtent; - } - - MultiStageReorder getReorderExtent() { - return reorderExtent; + // pkg private for TracedEditSession only, may later become public API + boolean commitRequired() { + if (isQueueEnabled() && reorderExtent.commitRequired()) { + return true; + } + if (isBatchingChunks() && chunkBatchingExtent.commitRequired()) { + return true; + } + return false; } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/TracedEditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/TracedEditSession.java index 046046795..5793a4f04 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/TracedEditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/TracedEditSession.java @@ -37,11 +37,8 @@ public class TracedEditSession extends EditSession { @Override protected void finalize() throws Throwable { super.finalize(); - if (!isQueueEnabled() && !isBatchingChunks()) { - return; - } - if (getChunkBatchingExtent().commitRequired() || getReorderExtent().commitRequired()) { + if (commitRequired()) { WorldEdit.logger.warning("####### LEFTOVER BUFFER BLOCKS DETECTED #######"); WorldEdit.logger.warning("This means that some code did not flush their EditSession."); WorldEdit.logger.log(Level.WARNING, "Here is a stacktrace from the creation of this EditSession:", stacktrace);