Skip to content
Permalink
Browse files

Apply watchdog mode to undo/redo. Abstract EditSession creation logic.

  • Loading branch information...
wizjany committed Sep 30, 2019
1 parent 3093c45 commit 91f92a46fe88ef7fae990c9b6f9bc906d57e300a
Showing with 9 additions and 15 deletions.
  1. +9 −15 worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java
@@ -239,12 +239,7 @@ public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
EditSession editSession = history.get(historyPointer);
try (EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory()
.getEditSession(editSession.getWorld(), -1, newBlockBag, actor)) {
newEditSession.enableStandardMode();
newEditSession.setReorderMode(reorderMode);
newEditSession.setFastMode(fastMode);
if (newEditSession.getSurvivalExtent() != null) {
newEditSession.getSurvivalExtent().setStripNbt(!actor.hasPermission("worldedit.setnbt"));
}
prepareEditingExtents(editSession, actor);
editSession.undo(newEditSession);
}
return editSession;
@@ -267,12 +262,7 @@ public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
EditSession editSession = history.get(historyPointer);
try (EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory()
.getEditSession(editSession.getWorld(), -1, newBlockBag, actor)) {
newEditSession.enableStandardMode();
newEditSession.setReorderMode(reorderMode);
newEditSession.setFastMode(fastMode);
if (newEditSession.getSurvivalExtent() != null) {
newEditSession.getSurvivalExtent().setStripNbt(!actor.hasPermission("worldedit.setnbt"));
}
prepareEditingExtents(editSession, actor);
editSession.redo(newEditSession);
}
++historyPointer;
@@ -954,15 +944,19 @@ public EditSession createEditSession(Actor actor) {
}
Request.request().setEditSession(editSession);

editSession.setMask(mask);
prepareEditingExtents(editSession, actor);

return editSession;
}

private void prepareEditingExtents(EditSession editSession, Actor actor) {
editSession.setFastMode(fastMode);
editSession.setReorderMode(reorderMode);
editSession.setMask(mask);
if (editSession.getSurvivalExtent() != null) {
editSession.getSurvivalExtent().setStripNbt(!actor.hasPermission("worldedit.setnbt"));
}
editSession.setTickingWatchdog(tickingWatchdog);

return editSession;
}

/**

0 comments on commit 91f92a4

Please sign in to comment.
You can’t perform that action at this time.