From 8da1224e0863f37ddac6beec789b4e8b09eddb64 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 8 Sep 2018 08:23:01 +1000 Subject: [PATCH] Fix undo --- .../java/com/boydti/fawe/util/MainUtil.java | 4 +- .../worldedit/command/HistoryCommands.java | 42 +++++++++---------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/util/MainUtil.java b/core/src/main/java/com/boydti/fawe/util/MainUtil.java index 8046c221..7f2e2f98 100644 --- a/core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -1051,9 +1051,9 @@ public class MainUtil { public static void deleteOlder(File directory, final long timeDiff, boolean printDebug) { final long now = System.currentTimeMillis(); ForkJoinPool pool = new ForkJoinPool(); - iterateFiles(directory, new RunnableVal() { + iterateFiles(directory, new Consumer() { @Override - public void run(File file) { + public void accept(File file) { long age = now - file.lastModified(); if (age > timeDiff) { pool.submit(() -> file.delete()); diff --git a/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java b/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java index b200a5b5..d36d82c1 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java @@ -232,31 +232,29 @@ public class HistoryCommands extends MethodCommands { @CommandPermissions("worldedit.history.undo") public void undo(Player player, LocalSession session, CommandContext context) throws WorldEditException { int times = Math.max(1, context.getInteger(0, 1)); - if (times > 50) { - FawePlayer.wrap(player).checkConfirmation(() -> { - for (int i = 0; i < times; ++i) { - EditSession undone; - if (context.argsLength() < 2) { - undone = session.undo(session.getBlockBag(player), player); - } else { - player.checkPermission("worldedit.history.undo.other"); - LocalSession sess = worldEdit.getSession(context.getString(1)); - if (sess == null) { - BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, context.getString(1)); - break; - } - undone = sess.undo(session.getBlockBag(player), player); - } - if (undone != null) { - BBC.COMMAND_UNDO_SUCCESS.send(player); - worldEdit.flushBlockBag(player, undone); - } else { - BBC.COMMAND_UNDO_ERROR.send(player); + FawePlayer.wrap(player).checkConfirmation(() -> { + for (int i = 0; i < times; ++i) { + EditSession undone; + if (context.argsLength() < 2) { + undone = session.undo(session.getBlockBag(player), player); + } else { + player.checkPermission("worldedit.history.undo.other"); + LocalSession sess = worldEdit.getSessionManager().findByName(context.getString(1)); + if (sess == null) { + BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, context.getString(1)); break; } + undone = sess.undo(session.getBlockBag(player), player); } - }, getArguments(context), times, 50); - } + if (undone != null) { + BBC.COMMAND_UNDO_SUCCESS.send(player); + worldEdit.flushBlockBag(player, undone); + } else { + BBC.COMMAND_UNDO_ERROR.send(player); + break; + } + } + }, getArguments(context), times, 50); } @Command(