From 926f6a6ab868af69731d684104ef6fb06f15d815 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 9 Dec 2018 15:33:35 +1000 Subject: [PATCH] Flush undo/redo --- .../com/sk89q/worldedit/LocalSession.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 2dc413932..9b117c918 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -93,7 +93,7 @@ public class LocalSession { private transient Mask mask; private transient TimeZone timezone = TimeZone.getDefault(); private transient BlockVector3 cuiTemporaryBlock; - private transient EditSession.ReorderMode reorderMode = EditSession.ReorderMode.FAST; + private transient EditSession.ReorderMode reorderMode = EditSession.ReorderMode.MULTI_STAGE; // Saved properties private String lastScript; @@ -226,12 +226,13 @@ public class LocalSession { --historyPointer; if (historyPointer >= 0) { EditSession editSession = history.get(historyPointer); - EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() - .getEditSession(editSession.getWorld(), -1, newBlockBag, player); - newEditSession.enableStandardMode(); - newEditSession.setReorderMode(reorderMode); - newEditSession.setFastMode(fastMode); - editSession.undo(newEditSession); + try (EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() + .getEditSession(editSession.getWorld(), -1, newBlockBag, player)) { + newEditSession.enableStandardMode(); + newEditSession.setReorderMode(reorderMode); + newEditSession.setFastMode(fastMode); + editSession.undo(newEditSession); + } return editSession; } else { historyPointer = 0; @@ -250,12 +251,13 @@ public class LocalSession { checkNotNull(player); if (historyPointer < history.size()) { EditSession editSession = history.get(historyPointer); - EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() - .getEditSession(editSession.getWorld(), -1, newBlockBag, player); - newEditSession.enableStandardMode(); - newEditSession.setReorderMode(reorderMode); - newEditSession.setFastMode(fastMode); - editSession.redo(newEditSession); + try (EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() + .getEditSession(editSession.getWorld(), -1, newBlockBag, player)) { + newEditSession.enableStandardMode(); + newEditSession.setReorderMode(reorderMode); + newEditSession.setFastMode(fastMode); + editSession.redo(newEditSession); + } ++historyPointer; return editSession; }