This commit is contained in:
TomyLobo
2011-11-23 02:29:48 +01:00
parent 1a57f6e95d
commit 7e13b60a51
161 changed files with 1433 additions and 1412 deletions

View File

@ -75,7 +75,7 @@ public class BrushCommands {
Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill);
tool.setSize(radius);
if (args.hasFlag('h')) {
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
} else {
@ -119,13 +119,13 @@ public class BrushCommands {
Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill);
tool.setSize(radius);
if (args.hasFlag('h')) {
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
} else {
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
}
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
radius, height));
}
@ -144,14 +144,14 @@ public class BrushCommands {
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
CuboidClipboard clipboard = session.getClipboard();
if (clipboard == null) {
player.printError("Copy something first.");
return;
}
Vector size = clipboard.getSize();
if (size.getBlockX() > config.maxBrushRadius
@ -164,7 +164,7 @@ public class BrushCommands {
BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
player.print("Clipboard brush shape equipped.");
}
@ -199,7 +199,7 @@ public class BrushCommands {
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
radius, iterations));
}
@Command(
aliases = { "ex", "extinguish" },
usage = "[radius]",

View File

@ -97,7 +97,7 @@ public class ChunkCommands {
player.print("Note that this command does not yet support the mcregion format.");
LocalConfiguration config = we.getConfiguration();
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
FileOutputStream out = null;
@ -129,7 +129,9 @@ public class ChunkCommands {
player.printError("Error occurred: " + e.getMessage());
} finally {
if (out != null) {
try { out.close(); } catch (IOException ie) {}
try {
out.close();
} catch (IOException ie) { }
}
}
} else if (config.shellSaveType.equalsIgnoreCase("bash")) {

View File

@ -82,7 +82,7 @@ public class ClipboardCommands {
if (args.argsLength() > 0) {
block = we.getBlock(player, args.getString(0));
}
Region region = session.getSelection(player.getWorld());
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
@ -97,7 +97,7 @@ public class ClipboardCommands {
editSession.setBlocks(session.getSelection(player.getWorld()), block);
player.print("Block(s) cut.");
}
@Command(
aliases = { "/paste" },
usage = "",
@ -114,7 +114,7 @@ public class ClipboardCommands {
boolean atOrigin = args.hasFlag('o');
boolean pasteNoAir = args.hasFlag('a');
if (atOrigin) {
Vector pos = session.getClipboard().getOrigin();
session.getClipboard().place(editSession, pos, pasteNoAir);
@ -141,7 +141,7 @@ public class ClipboardCommands {
throws WorldEditException {
int angle = args.getInteger(0);
if (angle % 90 == 0) {
CuboidClipboard clipboard = session.getClipboard();
clipboard.rotate2D(angle);
@ -171,7 +171,7 @@ public class ClipboardCommands {
clipboard.flip(dir, args.hasFlag('p'));
player.print("Clipboard flipped.");
}
@Command(
aliases = { "/load" },
usage = "<filename>",
@ -189,7 +189,7 @@ public class ClipboardCommands {
String filename = args.getString(0);
File dir = we.getWorkingDirectoryFile(config.saveDir);
File f = we.getSafeOpenFile(player, dir, filename, "schematic",
new String[] {"schematic"});
new String[] { "schematic" });
try {
String filePath = f.getCanonicalPath();
@ -208,7 +208,7 @@ public class ClipboardCommands {
player.printError("Schematic could not read or it does not exist: " + e.getMessage());
}
}
@Command(
aliases = { "/save" },
usage = "<filename>",
@ -227,7 +227,7 @@ public class ClipboardCommands {
File dir = we.getWorkingDirectoryFile(config.saveDir);
File f = we.getSafeSaveFile(player, dir, filename, "schematic",
new String[] {"schematic"});
new String[] { "schematic" });
if (!dir.exists()) {
if (!dir.mkdir()) {
@ -252,7 +252,7 @@ public class ClipboardCommands {
player.printError("Schematic could not written: " + e.getMessage());
}
}
@Command(
aliases = { "clearclipboard" },
usage = "",

View File

@ -56,7 +56,7 @@ public class GeneralCommands {
return;
}
}
session.setBlockChangeLimit(limit);
player.print("Block change limit set to " + limit + ".");
}
@ -147,27 +147,27 @@ public class GeneralCommands {
String query = args.getString(0).trim().toLowerCase();
boolean blocksOnly = args.hasFlag('b');
boolean itemsOnly = args.hasFlag('i');
try {
int id = Integer.parseInt(query);
ItemType type = ItemType.fromID(id);
if (type != null) {
player.print("#" + type.getID() + " (" + type.getName() + ")");
} else {
player.printError("No item found by ID " + id);
}
return;
} catch (NumberFormatException e) {
}
if (query.length() <= 2) {
player.printError("Enter a longer search string (len > 2).");
return;
}
if (!blocksOnly && !itemsOnly) {
player.print("Searching for: " + query);
} else if (blocksOnly && itemsOnly) {
@ -178,23 +178,23 @@ public class GeneralCommands {
} else {
player.print("Searching for items: " + query);
}
int found = 0;
for (ItemType type : ItemType.values()) {
if (found >= 15) {
player.print("Too many results!");
break;
}
if (blocksOnly && type.getID() > 255) {
continue;
}
if (itemsOnly && type.getID() <= 255) {
continue;
}
for (String alias : type.getAliases()) {
if (alias.contains(query)) {
player.print("#" + type.getID() + " (" + type.getName() + ")");
@ -203,7 +203,7 @@ public class GeneralCommands {
}
}
}
if (found == 0) {
player.printError("No items found.");
}

View File

@ -229,12 +229,12 @@ public class GenerationCommands {
player.printError("Tree type '" + args.getString(1) + "' is unknown.");
return;
}
int affected = editSession.makeForest(player.getPosition(),
size, density, new TreeGenerator(type));
player.print(affected + " trees created.");
}
@Command(
aliases = { "pumpkins" },
usage = "[size]",
@ -253,7 +253,7 @@ public class GenerationCommands {
int affected = editSession.makePumpkinPatches(player.getPosition(), size);
player.print(affected + " pumpkin patches created.");
}
@Command(
aliases = { "/pyramid" },
usage = "<block> <size>",
@ -270,13 +270,13 @@ public class GenerationCommands {
Pattern block = we.getBlockPattern(player, args.getString(0));
int size = Math.max(1, args.getInteger(1));
Vector pos = session.getPlacementPosition(player);
int affected = editSession.makePyramid(pos, block, size, true);
player.findFreePosition();
player.print(affected + " block(s) have been created.");
}
@Command(
aliases = { "/hpyramid" },
usage = "<block> <size>",
@ -293,9 +293,9 @@ public class GenerationCommands {
Pattern block = we.getBlockPattern(player, args.getString(0));
int size = Math.max(1, args.getInteger(1));
Vector pos = session.getPlacementPosition(player);
int affected = editSession.makePyramid(pos, block, size, false);
player.findFreePosition();
player.print(affected + " block(s) have been created.");
}

View File

@ -50,7 +50,7 @@ public class HistoryCommands {
} else {
player.checkPermission("worldedit.history.undo.other");
LocalSession sess = we.getSession(args.getString(1));
if (sess == null){
if (sess == null) {
player.printError("Unable to find session for " + args.getString(1));
break;
}
@ -65,7 +65,7 @@ public class HistoryCommands {
}
}
}
@Command(
aliases = { "/redo", "redo" },
usage = "[times] [player]",
@ -79,7 +79,7 @@ public class HistoryCommands {
throws WorldEditException {
int times = Math.max(1, args.getInteger(0, 1));
for (int i = 0; i < times; ++i) {
EditSession redone;
if (args.argsLength() < 2) {
@ -87,7 +87,7 @@ public class HistoryCommands {
} else {
player.checkPermission("worldedit.history.redo.other");
LocalSession sess = we.getSession(args.getString(1));
if (sess == null){
if (sess == null) {
player.printError("Unable to find session for " + args.getString(1));
break;
}

View File

@ -74,7 +74,6 @@ public class NavigationCommands {
} else {
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
}
}
@Command(
@ -103,7 +102,6 @@ public class NavigationCommands {
} else {
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
}
}
@Command(
@ -128,7 +126,7 @@ public class NavigationCommands {
player.printError("No free spot above you found.");
}
}
@Command(
aliases = { "thru" },
usage = "",

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands;
import java.util.Set;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
@ -57,16 +56,16 @@ public class RegionCommands {
throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
int affected;
if (pattern instanceof SingleBlockPattern) {
affected = editSession.setBlocks(session.getSelection(player.getWorld()),
((SingleBlockPattern) pattern).getBlock());
} else {
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
}
player.print(affected + " block(s) have been changed.");
}
@ -101,10 +100,10 @@ public class RegionCommands {
} else {
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
}
player.print(affected + " block(s) have been replaced.");
}
@Command(
aliases = { "/overlay" },
usage = "<block>",
@ -169,7 +168,7 @@ public class RegionCommands {
} else {
affected = editSession.makeCuboidWalls(session.getSelection(player.getWorld()), pattern);
}
player.print(affected + " block(s) have been changed.");
}
@ -220,7 +219,7 @@ public class RegionCommands {
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations);
player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
}
@Command(
@ -267,7 +266,6 @@ public class RegionCommands {
player.print(affected + " blocks moved.");
}
@Command(
aliases = { "/stack" },

View File

@ -48,7 +48,7 @@ public class ScriptingCommands {
String[] scriptArgs = args.getSlice(1);
String name = args.getString(0);
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
player.printError("You don't have permission to use that script.");
return;
@ -58,8 +58,8 @@ public class ScriptingCommands {
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, name, "js",
new String[] {"js"});
new String[] { "js" });
we.runScript(player, f, scriptArgs);
}
@ -77,12 +77,12 @@ public class ScriptingCommands {
throws WorldEditException {
String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
player.printError("You don't have permission to use that script.");
return;
}
if (lastScript == null) {
player.printError("Use /cs with a script name first.");
return;
@ -92,8 +92,8 @@ public class ScriptingCommands {
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, lastScript, "js",
new String[] {"js"});
new String[] { "js" });
we.runScript(player, f, scriptArgs);
}
}

View File

@ -87,11 +87,11 @@ public class SelectionCommands {
throws WorldEditException {
Vector pos;
if(args.argsLength() == 1) {
if(args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(",");
pos = new Vector(Integer.parseInt(coords[0]),
Integer.parseInt(coords[1]),
pos = new Vector(Integer.parseInt(coords[0]),
Integer.parseInt(coords[1]),
Integer.parseInt(coords[2]));
} else {
player.printError("Invalid coordinates " + args.getString(0));
@ -106,7 +106,6 @@ public class SelectionCommands {
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos);
}
@ -124,7 +123,7 @@ public class SelectionCommands {
throws WorldEditException {
Vector pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld())
.selectPrimary(pos)) {
@ -152,7 +151,7 @@ public class SelectionCommands {
throws WorldEditException {
Vector pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld())
.selectSecondary(pos)) {
@ -208,11 +207,11 @@ public class SelectionCommands {
selector.selectPrimary(min);
selector.selectSecondary(max);
session.setRegionSelector(player.getWorld(), selector);
session.dispatchCUISelection(player);
}
@Command(
aliases = { "/wand" },
usage = "",
@ -228,7 +227,7 @@ public class SelectionCommands {
player.giveItem(we.getConfiguration().wandItem, 1);
player.print("Left click: select pos #1; Right click: select pos #2");
}
@Command(
aliases = { "toggleeditwand" },
usage = "",
@ -242,7 +241,7 @@ public class SelectionCommands {
throws WorldEditException {
session.setToolControl(!session.isToolControlEnabled());
if (session.isToolControlEnabled()) {
player.print("Edit wand enabled.");
} else {
@ -281,13 +280,13 @@ public class SelectionCommands {
} catch (RegionOperationException e) {
player.printError(e.getMessage());
}
return;
}
int change = args.getInteger(0);
int reverseChange = 0;
switch (args.argsLength()) {
case 2:
// Either a reverse amount or a direction
@ -300,7 +299,7 @@ public class SelectionCommands {
}
break;
case 3:
case 3:
// Both reverse amount and direction
reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player,
@ -313,16 +312,16 @@ public class SelectionCommands {
Region region = session.getSelection(player.getWorld());
int oldSize = region.getArea();
region.expand(dir.multiply(change));
if (reverseChange != 0) {
region.expand(dir.multiply(reverseChange));
}
session.getRegionSelector().learnChanges();
int newSize = region.getArea();
session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region expanded " + (newSize - oldSize) + " blocks.");
}
@ -353,7 +352,7 @@ public class SelectionCommands {
}
break;
case 3:
case 3:
// Both reverse amount and direction
reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player, args.getString(2).toLowerCase());
@ -371,9 +370,9 @@ public class SelectionCommands {
}
session.getRegionSelector().learnChanges();
int newSize = region.getArea();
session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region contracted " + (oldSize - newSize) + " blocks.");
} catch (RegionOperationException e) {
player.printError(e.getMessage());
@ -392,7 +391,7 @@ public class SelectionCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
Vector dir;
int change = args.getInteger(0);
if (args.argsLength() == 2) {
dir = we.getDirection(player, args.getString(1).toLowerCase());
@ -405,9 +404,9 @@ public class SelectionCommands {
region.expand(dir.multiply(change));
region.contract(dir.multiply(change));
session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region shifted.");
} catch (RegionOperationException e) {
player.printError(e.getMessage());
@ -429,13 +428,13 @@ public class SelectionCommands {
int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld());
try {
if (!args.hasFlag('h')) {
region.expand((new Vector(0, 1, 0)).multiply(change));
region.expand((new Vector(0, -1, 0)).multiply(change));
}
if (!args.hasFlag('v')) {
region.expand((new Vector(1, 0, 0)).multiply(change));
region.expand((new Vector(-1, 0, 0)).multiply(change));
@ -444,9 +443,9 @@ public class SelectionCommands {
}
session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region outset.");
} catch (RegionOperationException e) {
player.printError(e.getMessage());
@ -468,12 +467,12 @@ public class SelectionCommands {
int change = args.getInteger(0);
Region region = session.getSelection(player.getWorld());
if (!args.hasFlag('h')) {
region.contract((new Vector(0, 1, 0)).multiply(change));
region.contract((new Vector(0, -1, 0)).multiply(change));
}
if (!args.hasFlag('v')) {
region.contract((new Vector(1, 0, 0)).multiply(change));
region.contract((new Vector(-1, 0, 0)).multiply(change));
@ -482,9 +481,9 @@ public class SelectionCommands {
}
session.getRegionSelector().learnChanges();
session.getRegionSelector().explainRegionAdjust(player, session);
player.print("Region inset.");
}
@ -506,11 +505,11 @@ public class SelectionCommands {
.add(1, 1, 1);
player.print("Type: " + session.getRegionSelector().getTypeName());
for (String line : session.getRegionSelector().getInformationLines()) {
player.print(line);
}
player.print("Size: " + size);
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.print("# of blocks: " + region.getArea());
@ -548,28 +547,28 @@ public class SelectionCommands {
throws WorldEditException {
List<Countable<Integer>> distribution =
editSession.getBlockDistribution(session.getSelection(player.getWorld()));
editSession.getBlockDistribution(session.getSelection(player.getWorld()));
Logger logger = Logger.getLogger("Minecraft.WorldEdit");
if (distribution.size() > 0) { // *Should* always be true
int size = session.getSelection(player.getWorld()).getArea();
player.print("# total blocks: " + size);
if (args.hasFlag('c')) {
logger.info("Block distribution (req. by " + player.getName() + "):");
logger.info("# total blocks: " + size);
}
for (Countable<Integer> c : distribution) {
BlockType block = BlockType.fromID(c.getID());
String str = String.format("%-7s (%.3f%%) %s #%d",
String.valueOf(c.getAmount()),
c.getAmount() / (double)size * 100,
c.getAmount() / (double) size * 100,
block == null ? "Unknown" : block.getName(), c.getID());
player.print(str);
if (args.hasFlag('c')) {
logger.info(str);
}

View File

@ -65,9 +65,9 @@ public class SnapshotCommands {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
if (snapshots.size() > 0) {
int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5;
player.print("Snapshots for world: '" + player.getWorld().getName() + "'");
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
player.print((i + 1) + ". " + snapshots.get(i).getName());

View File

@ -32,7 +32,7 @@ import com.sk89q.worldedit.tools.AreaPickaxe;
import com.sk89q.worldedit.tools.RecursivePickaxe;
import com.sk89q.worldedit.tools.SinglePickaxe;
public class SuperPickaxeCommands {
public class SuperPickaxeCommands {
@Command(
aliases = { "single" },
usage = "",
@ -49,7 +49,7 @@ public class SuperPickaxeCommands {
session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable.");
}
@Command(
aliases = { "area" },
usage = "<radius>",
@ -64,17 +64,17 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(0);
if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
return;
}
session.setSuperPickaxe(new AreaPickaxe(range));
session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable.");
}
@Command(
aliases = { "recur", "recursive" },
usage = "<radius>",
@ -89,12 +89,12 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration();
double range = args.getDouble(0);
if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
return;
}
session.setSuperPickaxe(new RecursivePickaxe(range));
session.enableSuperPickAxe();
player.print("Mode changed. Left click with a pickaxe. // to disable.");

View File

@ -138,7 +138,7 @@ public class ToolCommands {
LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(1);
if (range > config.maxSuperPickaxeSize) {
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
return;
@ -159,7 +159,7 @@ public class ToolCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
}
@Command(
aliases = { "deltree" },
usage = "",

View File

@ -151,14 +151,14 @@ public class ToolUtilCommands {
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int radius = args.getInteger(0);
if (radius > config.maxBrushRadius) {
player.printError("Maximum allowed brush radius: "
+ config.maxBrushRadius);
return;
}
session.getBrushTool(player.getItemInHand()).setSize(radius);
player.print("Brush size set.");
}

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.commands;
import java.util.Set;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
@ -97,7 +96,7 @@ public class UtilityCommands {
}
player.print(affected + " block(s) have been created.");
}
@Command(
aliases = { "/drain" },
usage = "<radius>",
@ -260,7 +259,7 @@ public class UtilityCommands {
}
player.print(affected + " block(s) have been replaced.");
}
@Command(
aliases = { "/snow", "snow" },
usage = "[radius]",
@ -332,7 +331,7 @@ public class UtilityCommands {
throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0))
: defaultRadius;
@ -378,12 +377,12 @@ public class UtilityCommands {
String typeStr = args.getString(0);
int radius = args.getInteger(1);
if (radius < -1) {
player.printError("Use -1 to remove all entities in loaded chunks");
return;
}
EntityType type = null;
if (typeStr.matches("arrows?")) {

View File

@ -34,7 +34,7 @@ import com.sk89q.worldedit.WorldEditException;
public class WorldEditCommands {
private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
@Command(
aliases = { "version", "ver" },
usage = "",