Added multiple undo/redo, fixed compile error.

Dieser Commit ist enthalten in:
sk89q 2011-02-18 21:19:54 -08:00
Ursprung abaeaa99ac
Commit 7088fadab8
3 geänderte Dateien mit 31 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -80,10 +80,10 @@ commands:
usage: /<command> usage: /<command>
/redo: /redo:
description: Redoes the last action (from history) description: Redoes the last action (from history)
usage: /<command> usage: /<command> [times]
/undo: /undo:
description: Undoes the last action description: Undoes the last action
usage: /<command> usage: /<command> [times]
unstuck: unstuck:
description: Escape from being stuck inside a block description: Escape from being stuck inside a block
usage: /<command> usage: /<command>

Datei anzeigen

@ -47,9 +47,9 @@ import com.sk89q.worldedit.regions.Region;
public class WorldEditPlugin extends JavaPlugin { public class WorldEditPlugin extends JavaPlugin {
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit"); private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private final ServerInterface server; final ServerInterface server;
private final WorldEdit controller; final WorldEdit controller;
private final WorldEditAPI api; final WorldEditAPI api;
private final LocalConfiguration config; private final LocalConfiguration config;
private final PermissionsResolverManager perms; private final PermissionsResolverManager perms;

Datei anzeigen

@ -32,43 +32,52 @@ import com.sk89q.worldedit.*;
public class HistoryCommands { public class HistoryCommands {
@Command( @Command(
aliases = {"/undo"}, aliases = {"/undo"},
usage = "", usage = "[times]",
desc = "Undoes the last action", desc = "Undoes the last action",
min = 0, min = 0,
max = 0 max = 1
) )
@CommandPermissions({"worldedit.history.undo"}) @CommandPermissions({"worldedit.history.undo"})
public static void undo(CommandContext args, WorldEdit we, public static void undo(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
EditSession undone = session.undo(session.getBlockBag(player)); int times = Math.max(1, args.getInteger(0, 1));
if (undone != null) {
player.print("Undo successful."); for (int i = 0; i < times; i++) {
we.flushBlockBag(player, undone); EditSession undone = session.undo(session.getBlockBag(player));
} else { if (undone != null) {
player.printError("Nothing to undo."); player.print("Undo successful.");
we.flushBlockBag(player, undone);
} else {
player.printError("Nothing left to undo.");
break;
}
} }
} }
@Command( @Command(
aliases = {"/redo"}, aliases = {"/redo"},
usage = "", usage = "[times]",
desc = "Redoes the last action (from history)", desc = "Redoes the last action (from history)",
min = 0, min = 0,
max = 0 max = 1
) )
@CommandPermissions({"worldedit.history.redo"}) @CommandPermissions({"worldedit.history.redo"})
public static void redo(CommandContext args, WorldEdit we, public static void redo(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
EditSession redone = session.redo(session.getBlockBag(player)); int times = Math.max(1, args.getInteger(0, 1));
if (redone != null) {
player.print("Redo successful."); for (int i = 0; i < times; i++) {
we.flushBlockBag(player, redone); EditSession redone = session.redo(session.getBlockBag(player));
} else { if (redone != null) {
player.printError("Nothing to redo."); player.print("Redo successful.");
we.flushBlockBag(player, redone);
} else {
player.printError("Nothing left to redo.");
}
} }
} }