Snapshot commands put under /snap and /snapshot commands.

Dieser Commit ist enthalten in:
sk89q 2011-02-18 21:44:57 -08:00
Ursprung bc6ef48935
Commit 5254986da2
4 geänderte Dateien mit 238 neuen und 177 gelöschten Zeilen

Datei anzeigen

@ -23,9 +23,6 @@ commands:
delchunks: delchunks:
description: Delete chunks that your selection includes description: Delete chunks that your selection includes
usage: /<command> usage: /<command>
clearclipboard:
description: Clear your clipboard
usage: /<command>
/load: /load:
description: Load a schematic into your clipboard description: Load a schematic into your clipboard
usage: /<command> <filename> usage: /<command> <filename>
@ -47,6 +44,12 @@ commands:
/paste: /paste:
description: Paste the clipboard's contents description: Paste the clipboard's contents
usage: /<command> [-ao] usage: /<command> [-ao]
clearclipboard:
description: Clear your clipboard
usage: /<command>
/limit:
description: Modify block change limit
usage: /<command> <limit>
toggleplace: toggleplace:
description: description:
usage: /<command> usage: /<command>
@ -54,9 +57,6 @@ commands:
description: Search for an item description: Search for an item
usage: /<command> [-bi] <query> usage: /<command> [-bi] <query>
aliases: ['/l'] aliases: ['/l']
/limit:
description: Modify block change limit
usage: /<command> <limit>
/sphere: /sphere:
description: Generate a filled sphere description: Generate a filled sphere
usage: /<command> <block> <radius> [raised?] usage: /<command> <block> <radius> [raised?]
@ -75,17 +75,17 @@ commands:
pumpkins: pumpkins:
description: Generate pumpkin patches description: Generate pumpkin patches
usage: /<command> [size] usage: /<command> [size]
clearhistory:
description: Clear your history
usage: /<command>
/redo:
description: Redoes the last action (from history)
usage: /<command> [times]
aliases: ['redo']
/undo: /undo:
description: Undoes the last action description: Undoes the last action
usage: /<command> [times] usage: /<command> [times]
aliases: ['undo'] aliases: ['undo']
/redo:
description: Redoes the last action (from history)
usage: /<command> [times]
aliases: ['redo']
clearhistory:
description: Clear your history
usage: /<command>
unstuck: unstuck:
description: Escape from being stuck inside a block description: Escape from being stuck inside a block
usage: /<command> usage: /<command>
@ -95,18 +95,27 @@ commands:
descend: descend:
description: Go down a floor description: Go down a floor
usage: /<command> usage: /<command>
ceil:
description: Go to the celing
usage: /<command> [clearance]
thru: thru:
description: Passthrough walls description: Passthrough walls
usage: /<command> usage: /<command>
jumpto: jumpto:
description: Teleport to a location description: Teleport to a location
usage: /<command> usage: /<command>
ceil:
description: Go to the celing
usage: /<command> [clearance]
up: up:
description: Go upwards some distance description: Go upwards some distance
usage: /<command> <block> usage: /<command> <block>
/replace:
description: Replace all blocks in the selection with another
usage: /<command> [from-block] <to-block>
/stack:
description: Repeat the contents of the selection
usage: /<command> [-a] [count] [direction]
/set:
description: Set all the blocks inside the selection to a block
usage: /<command> <block>
/overlay: /overlay:
description: Set a block on top of blocks in the region description: Set a block on top of blocks in the region
usage: /<command> <block> usage: /<command> <block>
@ -120,24 +129,24 @@ commands:
/smooth: /smooth:
description: Smooth the elevation in the selection description: Smooth the elevation in the selection
usage: /<command> [iterations] usage: /<command> [iterations]
/replace:
description: Replace all blocks in the selection with another
usage: /<command> [from-block] <to-block>
/stack:
description: Repeat the contents of the selection
usage: /<command> [-a] [count] [direction]
/set:
description: Set all the blocks inside the selection to a block
usage: /<command> <block>
/move: /move:
description: Move the contents of the selection description: Move the contents of the selection
usage: /<command> [count] [direction] [leave-id] usage: /<command> [count] [direction] [leave-id]
.s:
description: Execute last CraftScript
usage: /<command> [args...]
cs: cs:
description: Execute a CraftScript description: Execute a CraftScript
usage: /<command> <filename> [args...] usage: /<command> <filename> [args...]
.s:
description: Execute last CraftScript
usage: /<command> [args...]
//count:
description: Counts the number of a certain type of block
usage: /<command> <block>
/size:
description: Get information about the selection
usage: /<command>
/shift:
description: Shift the selection area
usage: /<command> <amount> [direction]
/chunk: /chunk:
description: Set the selection to your current chunk description: Set the selection to your current chunk
usage: /<command> usage: /<command>
@ -159,36 +168,35 @@ commands:
toggleeditwand: toggleeditwand:
description: Toggle functionality of the edit wand description: Toggle functionality of the edit wand
usage: /<command> usage: /<command>
/contract:
description: Contract the selection area
usage: /<command> <amount> [reverse-amount] [direction]
/distr:
description: Get the distribution of blocks in the selection
usage: /<command>
//count:
description: Counts the number of a certain type of block
usage: /<command> <block>
/size:
description: Get information about the selection
usage: /<command>
/shift:
description: Shift the selection area
usage: /<command> <amount> [direction]
/expand: /expand:
description: Expand the selection area description: Expand the selection area
usage: /<command> <amount> [reverse-amount] <direction> usage: /<command> <amount> [reverse-amount] <direction>
/use: /contract:
description: Choose a snapshot to use description: Contract the selection area
usage: /<command> <snapshot> usage: /<command> <amount> [reverse-amount] [direction]
listsnapshots: /outset:
description: Outset the selection area
usage: /<command> [-hv] <amount>
/inset:
description: Inset the selection area
usage: /<command> [-hv] <amount>
/distr:
description: Get the distribution of blocks in the selection
usage: /<command> [-c]
list:
description: List snapshots description: List snapshots
usage: /<command> [num] usage: /<command> [num]
/restore: use:
description: Choose a snapshot to use
usage: /<command> <snapshot>
snapshot:
description: Snapshot commands
usage: /<command>
aliases: ['snap']
restore:
description: Restore the selection from a snapshot description: Restore the selection from a snapshot
usage: /<command> [snapshot] usage: /<command> [snapshot]
area: aliases: ['/restore']
description: Enable the area super pickaxe pickaxe mode
usage: /<command> <radius>
recur: recur:
description: Enable the recursive super pickaxe pickaxe mode description: Enable the recursive super pickaxe pickaxe mode
usage: /<command> <radius> usage: /<command> <radius>
@ -196,9 +204,18 @@ commands:
single: single:
description: Enable the single block super pickaxe mode description: Enable the single block super pickaxe mode
usage: /<command> usage: /<command>
area:
description: Enable the area super pickaxe pickaxe mode
usage: /<command> <radius>
info:
description: Block information tool
usage: /<command>
none: none:
description: Turn off all superpickaxe alternate modes description: Turn off all superpickaxe alternate modes
usage: /<command> usage: /<command>
tree:
description: Tree generator tool
usage: /<command> [type]
repl: repl:
description: Block replacer tool description: Block replacer tool
usage: /<command> <block> usage: /<command> <block>
@ -209,12 +226,9 @@ commands:
description: Brush tool description: Brush tool
usage: /<command> usage: /<command>
aliases: ['b'] aliases: ['b']
info: mask:
description: Block information tool description: Set the brush mask
usage: /<command> usage: /<command> [mask]
tree:
description: Tree generator tool
usage: /<command> [type]
tool: tool:
description: Select a tool to bind description: Select a tool to bind
usage: /<command> usage: /<command>
@ -227,12 +241,19 @@ commands:
description: Select super pickaxe mode description: Select super pickaxe mode
usage: /<command> usage: /<command>
aliases: ['pickaxe', 'sp'] aliases: ['pickaxe', 'sp']
mask: remove:
description: Set the brush mask description: Remove all entities of a type
usage: /<command> [mask] usage: /<command> <type> <radius>
aliases: ['rem', 'rement']
/fill:
description: Fill a hole
usage: /<command> <block> <radius> [depth]
/fillr: /fillr:
description: Fill a hole recursively description: Fill a hole recursively
usage: /<command> <block> <radius> [depth] usage: /<command> <block> <radius> [depth]
/drain:
description: Drain a pool
usage: /<command> <radius>
fixlava: fixlava:
description: Fix lava to be stationary description: Fix lava to be stationary
usage: /<command> <radius> usage: /<command> <radius>
@ -264,13 +285,3 @@ commands:
butcher: butcher:
description: Kill all or nearby mobs description: Kill all or nearby mobs
usage: /<command> [radius] usage: /<command> [radius]
remove:
description: Remove all entities of a type
usage: /<command> <type> <radius>
aliases: ['rem', 'rement']
/fill:
description: Fill a hole
usage: /<command> <block> <radius> [depth]
/drain:
description: Drain a pool
usage: /<command> <radius>

Datei anzeigen

@ -109,7 +109,7 @@ public class WorldEdit {
commands.register(RegionCommands.class); commands.register(RegionCommands.class);
commands.register(ScriptingCommands.class); commands.register(ScriptingCommands.class);
commands.register(SelectionCommands.class); commands.register(SelectionCommands.class);
commands.register(SnapshotCommands.class); commands.register(SnapshotUtilCommands.class);
commands.register(ToolUtilCommands.class); commands.register(ToolUtilCommands.class);
commands.register(ToolCommands.class); commands.register(ToolCommands.class);
commands.register(UtilityCommands.class); commands.register(UtilityCommands.class);

Datei anzeigen

@ -26,12 +26,8 @@ import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.data.ChunkStore;
import com.sk89q.worldedit.data.DataException;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.snapshots.InvalidSnapshotException; import com.sk89q.worldedit.snapshots.InvalidSnapshotException;
import com.sk89q.worldedit.snapshots.Snapshot; import com.sk89q.worldedit.snapshots.Snapshot;
import com.sk89q.worldedit.snapshots.SnapshotRestore;
/** /**
* Snapshot commands. * Snapshot commands.
@ -42,7 +38,7 @@ public class SnapshotCommands {
private static Logger logger = Logger.getLogger("Minecraft.WorldEdit"); private static Logger logger = Logger.getLogger("Minecraft.WorldEdit");
@Command( @Command(
aliases = {"listsnapshots"}, aliases = {"list"},
usage = "[num]", usage = "[num]",
desc = "List snapshots", desc = "List snapshots",
min = 0, min = 0,
@ -66,7 +62,7 @@ public class SnapshotCommands {
player.print((i + 1) + ". " + snapshots[i].getName()); player.print((i + 1) + ". " + snapshots[i].getName());
} }
player.print("Use //use [snapshot] or //use latest to set the snapshot."); player.print("Use /snap use [snapshot] or /snap use latest.");
} else { } else {
player.printError("No snapshots are available. See console for details."); player.printError("No snapshots are available. See console for details.");
@ -88,7 +84,7 @@ public class SnapshotCommands {
} }
@Command( @Command(
aliases = {"/use"}, aliases = {"use"},
usage = "<snapshot>", usage = "<snapshot>",
desc = "Choose a snapshot to use", desc = "Choose a snapshot to use",
min = 1, min = 1,
@ -127,103 +123,4 @@ public class SnapshotCommands {
} }
} }
} }
@Command(
aliases = {"/restore"},
usage = "[snapshot]",
desc = "Restore the selection from a snapshot",
min = 0,
max = 1
)
@CommandPermissions({"worldedit.snapshots.restore"})
public static void restore(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
player.printError("Snapshot/backup restore is not configured.");
return;
}
Region region = session.getRegion();
Snapshot snapshot;
if (args.argsLength() > 0) {
try {
snapshot = config.snapshotRepo.getSnapshot(args.getString(0));
} catch (InvalidSnapshotException e) {
player.printError("That snapshot does not exist or is not available.");
return;
}
} else {
snapshot = session.getSnapshot();
}
ChunkStore chunkStore = null;
// No snapshot set?
if (snapshot == null) {
snapshot = config.snapshotRepo.getDefaultSnapshot();
if (snapshot == null) {
player.printError("No snapshots were found. See console for details.");
// Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory();
try {
logger.info("WorldEdit found no snapshots: looked in: " +
dir.getCanonicalPath());
} catch (IOException e) {
logger.info("WorldEdit found no snapshots: looked in "
+ "(NON-RESOLVABLE PATH - does it exist?): " +
dir.getPath());
}
return;
}
}
// Load chunk store
try {
chunkStore = snapshot.getChunkStore();
player.print("Snapshot '" + snapshot.getName() + "' loaded; now restoring...");
} catch (DataException e) {
player.printError("Failed to load snapshot: " + e.getMessage());
return;
} catch (IOException e) {
player.printError("Failed to load snapshot: " + e.getMessage());
return;
}
try {
// Restore snapshot
SnapshotRestore restore = new SnapshotRestore(chunkStore, region);
//player.print(restore.getChunksAffected() + " chunk(s) will be loaded.");
restore.restore(editSession);
if (restore.hadTotalFailure()) {
String error = restore.getLastErrorMessage();
if (error != null) {
player.printError("Errors prevented any blocks from being restored.");
player.printError("Last error: " + error);
} else {
player.printError("No chunks could be loaded. (Bad archive?)");
}
} else {
player.print(String.format("Restored; %d "
+ "missing chunks and %d other errors.",
restore.getMissingChunks().size(),
restore.getErrorChunks().size()));
}
} finally {
try {
chunkStore.close();
} catch (IOException e) {
}
}
}
} }

Datei anzeigen

@ -0,0 +1,153 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.commands;
import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.NestedCommand;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.data.ChunkStore;
import com.sk89q.worldedit.data.DataException;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.snapshots.InvalidSnapshotException;
import com.sk89q.worldedit.snapshots.Snapshot;
import com.sk89q.worldedit.snapshots.SnapshotRestore;
public class SnapshotUtilCommands {
private static Logger logger = Logger.getLogger("Minecraft.WorldEdit");
@Command(
aliases = {"snapshot", "snap"},
desc = "Snapshot commands"
)
@NestedCommand({SnapshotCommands.class})
public static void snapshot(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
}
@Command(
aliases = {"restore", "/restore"},
usage = "[snapshot]",
desc = "Restore the selection from a snapshot",
min = 0,
max = 1
)
@CommandPermissions({"worldedit.snapshots.restore"})
public static void restore(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
player.printError("Snapshot/backup restore is not configured.");
return;
}
Region region = session.getRegion();
Snapshot snapshot;
if (args.argsLength() > 0) {
try {
snapshot = config.snapshotRepo.getSnapshot(args.getString(0));
} catch (InvalidSnapshotException e) {
player.printError("That snapshot does not exist or is not available.");
return;
}
} else {
snapshot = session.getSnapshot();
}
ChunkStore chunkStore = null;
// No snapshot set?
if (snapshot == null) {
snapshot = config.snapshotRepo.getDefaultSnapshot();
if (snapshot == null) {
player.printError("No snapshots were found. See console for details.");
// Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory();
try {
logger.info("WorldEdit found no snapshots: looked in: " +
dir.getCanonicalPath());
} catch (IOException e) {
logger.info("WorldEdit found no snapshots: looked in "
+ "(NON-RESOLVABLE PATH - does it exist?): " +
dir.getPath());
}
return;
}
}
// Load chunk store
try {
chunkStore = snapshot.getChunkStore();
player.print("Snapshot '" + snapshot.getName() + "' loaded; now restoring...");
} catch (DataException e) {
player.printError("Failed to load snapshot: " + e.getMessage());
return;
} catch (IOException e) {
player.printError("Failed to load snapshot: " + e.getMessage());
return;
}
try {
// Restore snapshot
SnapshotRestore restore = new SnapshotRestore(chunkStore, region);
//player.print(restore.getChunksAffected() + " chunk(s) will be loaded.");
restore.restore(editSession);
if (restore.hadTotalFailure()) {
String error = restore.getLastErrorMessage();
if (error != null) {
player.printError("Errors prevented any blocks from being restored.");
player.printError("Last error: " + error);
} else {
player.printError("No chunks could be loaded. (Bad archive?)");
}
} else {
player.print(String.format("Restored; %d "
+ "missing chunks and %d other errors.",
restore.getMissingChunks().size(),
restore.getErrorChunks().size()));
}
} finally {
try {
chunkStore.close();
} catch (IOException e) {
}
}
}
}