3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 11:00:05 +01:00

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:
description: Delete chunks that your selection includes
usage: /<command>
clearclipboard:
description: Clear your clipboard
usage: /<command>
/load:
description: Load a schematic into your clipboard
usage: /<command> <filename>
@ -47,6 +44,12 @@ commands:
/paste:
description: Paste the clipboard's contents
usage: /<command> [-ao]
clearclipboard:
description: Clear your clipboard
usage: /<command>
/limit:
description: Modify block change limit
usage: /<command> <limit>
toggleplace:
description:
usage: /<command>
@ -54,9 +57,6 @@ commands:
description: Search for an item
usage: /<command> [-bi] <query>
aliases: ['/l']
/limit:
description: Modify block change limit
usage: /<command> <limit>
/sphere:
description: Generate a filled sphere
usage: /<command> <block> <radius> [raised?]
@ -75,17 +75,17 @@ commands:
pumpkins:
description: Generate pumpkin patches
usage: /<command> [size]
clearhistory:
description: Clear your history
usage: /<command>
/redo:
description: Redoes the last action (from history)
usage: /<command> [times]
aliases: ['redo']
/undo:
description: Undoes the last action
usage: /<command> [times]
aliases: ['undo']
/redo:
description: Redoes the last action (from history)
usage: /<command> [times]
aliases: ['redo']
clearhistory:
description: Clear your history
usage: /<command>
unstuck:
description: Escape from being stuck inside a block
usage: /<command>
@ -95,18 +95,27 @@ commands:
descend:
description: Go down a floor
usage: /<command>
ceil:
description: Go to the celing
usage: /<command> [clearance]
thru:
description: Passthrough walls
usage: /<command>
jumpto:
description: Teleport to a location
usage: /<command>
ceil:
description: Go to the celing
usage: /<command> [clearance]
up:
description: Go upwards some distance
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:
description: Set a block on top of blocks in the region
usage: /<command> <block>
@ -120,24 +129,24 @@ commands:
/smooth:
description: Smooth the elevation in the selection
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:
description: Move the contents of the selection
usage: /<command> [count] [direction] [leave-id]
.s:
description: Execute last CraftScript
usage: /<command> [args...]
cs:
description: Execute a CraftScript
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:
description: Set the selection to your current chunk
usage: /<command>
@ -159,36 +168,35 @@ commands:
toggleeditwand:
description: Toggle functionality of the edit wand
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:
description: Expand the selection area
usage: /<command> <amount> [reverse-amount] <direction>
/use:
description: Choose a snapshot to use
usage: /<command> <snapshot>
listsnapshots:
/contract:
description: Contract the selection area
usage: /<command> <amount> [reverse-amount] [direction]
/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
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
usage: /<command> [snapshot]
area:
description: Enable the area super pickaxe pickaxe mode
usage: /<command> <radius>
aliases: ['/restore']
recur:
description: Enable the recursive super pickaxe pickaxe mode
usage: /<command> <radius>
@ -196,9 +204,18 @@ commands:
single:
description: Enable the single block super pickaxe mode
usage: /<command>
area:
description: Enable the area super pickaxe pickaxe mode
usage: /<command> <radius>
info:
description: Block information tool
usage: /<command>
none:
description: Turn off all superpickaxe alternate modes
usage: /<command>
tree:
description: Tree generator tool
usage: /<command> [type]
repl:
description: Block replacer tool
usage: /<command> <block>
@ -209,12 +226,9 @@ commands:
description: Brush tool
usage: /<command>
aliases: ['b']
info:
description: Block information tool
usage: /<command>
tree:
description: Tree generator tool
usage: /<command> [type]
mask:
description: Set the brush mask
usage: /<command> [mask]
tool:
description: Select a tool to bind
usage: /<command>
@ -227,12 +241,19 @@ commands:
description: Select super pickaxe mode
usage: /<command>
aliases: ['pickaxe', 'sp']
mask:
description: Set the brush mask
usage: /<command> [mask]
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]
/fillr:
description: Fill a hole recursively
usage: /<command> <block> <radius> [depth]
/drain:
description: Drain a pool
usage: /<command> <radius>
fixlava:
description: Fix lava to be stationary
usage: /<command> <radius>
@ -264,13 +285,3 @@ commands:
butcher:
description: Kill all or nearby mobs
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(ScriptingCommands.class);
commands.register(SelectionCommands.class);
commands.register(SnapshotCommands.class);
commands.register(SnapshotUtilCommands.class);
commands.register(ToolUtilCommands.class);
commands.register(ToolCommands.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.CommandPermissions;
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.Snapshot;
import com.sk89q.worldedit.snapshots.SnapshotRestore;
/**
* Snapshot commands.
@ -42,7 +38,7 @@ public class SnapshotCommands {
private static Logger logger = Logger.getLogger("Minecraft.WorldEdit");
@Command(
aliases = {"listsnapshots"},
aliases = {"list"},
usage = "[num]",
desc = "List snapshots",
min = 0,
@ -66,7 +62,7 @@ public class SnapshotCommands {
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 {
player.printError("No snapshots are available. See console for details.");
@ -88,7 +84,7 @@ public class SnapshotCommands {
}
@Command(
aliases = {"/use"},
aliases = {"use"},
usage = "<snapshot>",
desc = "Choose a snapshot to use",
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) {
}
}
}
}