tweak undo message

This commit is contained in:
Jesse Boyd 2018-10-13 15:21:39 +11:00
parent 1a12c065a1
commit 888cbcedee
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 26 additions and 19 deletions

View File

@ -90,9 +90,9 @@ public enum BBC {
COMMAND_HISTORY_CLEAR("History cleared", "WorldEdit.History"), COMMAND_HISTORY_CLEAR("History cleared", "WorldEdit.History"),
COMMAND_REDO_ERROR("Nothing left to redo. (See also `/inspect` and `/frb`)", "WorldEdit.History"), COMMAND_REDO_ERROR("Nothing left to redo. (See also `/inspect` and `/frb`)", "WorldEdit.History"),
COMMAND_HISTORY_OTHER_ERROR("Unable to find session for %s0.", "WorldEdit.History"), COMMAND_HISTORY_OTHER_ERROR("Unable to find session for %s0.", "WorldEdit.History"),
COMMAND_REDO_SUCCESS("Redo successful.", "WorldEdit.History"), COMMAND_REDO_SUCCESS("Redo successful%s0.", "WorldEdit.History"),
COMMAND_UNDO_ERROR("Nothing left to undo. (See also `/inspect` and `/frb`)", "WorldEdit.History"), COMMAND_UNDO_ERROR("Nothing left to undo. (See also `/inspect` and `/frb`)", "WorldEdit.History"),
COMMAND_UNDO_SUCCESS("Undo successful.", "WorldEdit.History"), COMMAND_UNDO_SUCCESS("Undo successful%s0.", "WorldEdit.History"),
OPERATION("Operation queued (%s0)", "WorldEdit.Operation"), OPERATION("Operation queued (%s0)", "WorldEdit.Operation"),

View File

@ -226,8 +226,9 @@ public class HistoryCommands extends MethodCommands {
public void undo(Player player, LocalSession session, CommandContext context) throws WorldEditException { public void undo(Player player, LocalSession session, CommandContext context) throws WorldEditException {
int times = Math.max(1, context.getInteger(0, 1)); int times = Math.max(1, context.getInteger(0, 1));
FawePlayer.wrap(player).checkConfirmation(() -> { FawePlayer.wrap(player).checkConfirmation(() -> {
for (int i = 0; i < times; ++i) { EditSession undone = null;
EditSession undone; int i = 0;
for (; i < times; ++i) {
if (context.argsLength() < 2) { if (context.argsLength() < 2) {
undone = session.undo(session.getBlockBag(player), player); undone = session.undo(session.getBlockBag(player), player);
} else { } else {
@ -238,14 +239,16 @@ public class HistoryCommands extends MethodCommands {
break; break;
} }
undone = sess.undo(session.getBlockBag(player), player); undone = sess.undo(session.getBlockBag(player), player);
if (undone == null) break;
} }
if (undone != null) { }
BBC.COMMAND_UNDO_SUCCESS.send(player); if (undone == null) i--;
worldEdit.flushBlockBag(player, undone); if (i > 0) {
} else { BBC.COMMAND_UNDO_SUCCESS.send(player, i == 1 ? "" : " x" + i);
BBC.COMMAND_UNDO_ERROR.send(player); worldEdit.flushBlockBag(player, undone);
break; }
} if (undone == null) {
BBC.COMMAND_UNDO_ERROR.send(player);
} }
}, getArguments(context), times, 50, context); }, getArguments(context), times, 50, context);
} }
@ -262,8 +265,9 @@ public class HistoryCommands extends MethodCommands {
int times = Math.max(1, args.getInteger(0, 1)); int times = Math.max(1, args.getInteger(0, 1));
for (int i = 0; i < times; ++i) { EditSession redone = null;
EditSession redone; int i = 0;
for (; i < times; ++i) {
if (args.argsLength() < 2) { if (args.argsLength() < 2) {
redone = session.redo(session.getBlockBag(player), player); redone = session.redo(session.getBlockBag(player), player);
} else { } else {
@ -274,13 +278,16 @@ public class HistoryCommands extends MethodCommands {
break; break;
} }
redone = sess.redo(session.getBlockBag(player), player); redone = sess.redo(session.getBlockBag(player), player);
if (redone == null) break;
} }
if (redone != null) { }
BBC.COMMAND_REDO_SUCCESS.send(player); if (redone == null) i--;
worldEdit.flushBlockBag(player, redone); if (i > 0) {
} else { BBC.COMMAND_REDO_SUCCESS.send(player, i == 1 ? "" : " x" + i);
BBC.COMMAND_REDO_ERROR.send(player); worldEdit.flushBlockBag(player, redone);
} }
if (redone == null) {
BBC.COMMAND_REDO_ERROR.send(player);
} }
} }