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

Removed 'air' prefix from commands, made /worldeditselect permission more encompassing, and added syntax for //expand <amt> <reverse-amt> <direction> and //expand vert|vertical.

Dieser Commit ist enthalten in:
sk89q 2011-01-08 12:14:55 -08:00
Ursprung 7a2f1b58e2
Commit e57b89c0da

Datei anzeigen

@ -92,8 +92,6 @@ public class WorldEditController {
this.server = server; this.server = server;
this.config = config; this.config = config;
// Note: Commands should only have the phrase 'air' at the end
// for now (see SMWorldEditListener.canUseCommand)
commands.put("//pos1", "Set editing position #1"); commands.put("//pos1", "Set editing position #1");
commands.put("//pos2", "Set editing position #2"); commands.put("//pos2", "Set editing position #2");
commands.put("//hpos1", "Trace editing position #1"); commands.put("//hpos1", "Trace editing position #1");
@ -122,11 +120,8 @@ public class WorldEditController {
commands.put("//copy", "Copies the currently selected region"); commands.put("//copy", "Copies the currently selected region");
commands.put("//cut", "Cuts the currently selected region"); commands.put("//cut", "Cuts the currently selected region");
commands.put("//paste", "<AtOrigin?> - Pastes the clipboard"); commands.put("//paste", "<AtOrigin?> - Pastes the clipboard");
commands.put("//pasteair", "<AtOrigin?> - Pastes the clipboard (with air)");
commands.put("//move", "<Count> <Dir> <LeaveID> - Move the selection"); commands.put("//move", "<Count> <Dir> <LeaveID> - Move the selection");
commands.put("//moveair", "<Count> <Dir> <LeaveID> - Move the selection (with air)");
commands.put("//stack", "<Count> <Dir> - Stacks the selection"); commands.put("//stack", "<Count> <Dir> - Stacks the selection");
commands.put("//stackair", "<Count> <Dir> - Stacks the selection (with air)");
commands.put("//load", "[Filename] - Load .schematic into clipboard"); commands.put("//load", "[Filename] - Load .schematic into clipboard");
commands.put("//save", "[Filename] - Save clipboard to .schematic"); commands.put("//save", "[Filename] - Save clipboard to .schematic");
commands.put("//fill", "[ID] [Radius] <Depth> - Fill a hole"); commands.put("//fill", "[ID] [Radius] <Depth> - Fill a hole");
@ -750,8 +745,7 @@ public class WorldEditController {
return true; return true;
// Paste // Paste
} else if (split[0].equalsIgnoreCase("//pasteair") || } else if (split[0].equalsIgnoreCase("//paste")) {
split[0].equalsIgnoreCase("//paste")) {
checkArgs(split, 0, 1, split[0]); checkArgs(split, 0, 1, split[0]);
boolean atOrigin = split.length > 1 boolean atOrigin = split.length > 1
? (split[1].equalsIgnoreCase("true") ? (split[1].equalsIgnoreCase("true")
@ -759,14 +753,12 @@ public class WorldEditController {
: false; : false;
if (atOrigin) { if (atOrigin) {
Vector pos = session.getClipboard().getOrigin(); Vector pos = session.getClipboard().getOrigin();
session.getClipboard().place(editSession, pos, session.getClipboard().place(editSession, pos, false);
split[0].equalsIgnoreCase("//paste"));
player.findFreePosition(); player.findFreePosition();
player.print("Pasted to copy origin. Undo with //undo"); player.print("Pasted to copy origin. Undo with //undo");
} else { } else {
Vector pos = session.getPlacementPosition(player); Vector pos = session.getPlacementPosition(player);
session.getClipboard().paste(editSession, pos, session.getClipboard().paste(editSession, pos, false);
split[0].equalsIgnoreCase("//paste"));
player.findFreePosition(); player.findFreePosition();
player.print("Pasted relative to you. Undo with //undo"); player.print("Pasted relative to you. Undo with //undo");
} }
@ -1241,8 +1233,7 @@ public class WorldEditController {
return true; return true;
// Move // Move
} else if (split[0].equalsIgnoreCase("//moveair") || } else if (split[0].equalsIgnoreCase("//move")) {
split[0].equalsIgnoreCase("//move")) {
checkArgs(split, 0, 3, split[0]); checkArgs(split, 0, 3, split[0]);
int count = split.length > 1 ? Math.max(1, Integer.parseInt(split[1])) : 1; int count = split.length > 1 ? Math.max(1, Integer.parseInt(split[1])) : 1;
Vector dir = getDirection(player, Vector dir = getDirection(player,
@ -1256,36 +1247,54 @@ public class WorldEditController {
replace = new BaseBlock(0); replace = new BaseBlock(0);
} }
boolean copyAir = split[0].equalsIgnoreCase("//moveair");
int affected = editSession.moveCuboidRegion(session.getRegion(), int affected = editSession.moveCuboidRegion(session.getRegion(),
dir, count, copyAir, replace); dir, count, true, replace);
player.print(affected + " blocks moved."); player.print(affected + " blocks moved.");
return true; return true;
// Stack // Stack
} else if (split[0].equalsIgnoreCase("//stackair") || } else if (split[0].equalsIgnoreCase("//stack")) {
split[0].equalsIgnoreCase("//stack")) {
checkArgs(split, 0, 2, split[0]); checkArgs(split, 0, 2, split[0]);
int count = split.length > 1 ? Math.max(1, Integer.parseInt(split[1])) : 1; int count = split.length > 1 ? Math.max(1, Integer.parseInt(split[1])) : 1;
Vector dir = getDirection(player, Vector dir = getDirection(player,
split.length > 2 ? split[2].toLowerCase() : "me"); split.length > 2 ? split[2].toLowerCase() : "me");
boolean copyAir = split[0].equalsIgnoreCase("//stackair");
int affected = editSession.stackCuboidRegion(session.getRegion(), int affected = editSession.stackCuboidRegion(session.getRegion(),
dir, count, copyAir); dir, count, true);
player.print(affected + " blocks changed. Undo with //undo"); player.print(affected + " blocks changed. Undo with //undo");
return true; return true;
// Expand // Expand
} else if (split[0].equalsIgnoreCase("//expand")) { } else if (split[0].equalsIgnoreCase("//expand")) {
checkArgs(split, 1, 2, split[0]); checkArgs(split, 1, 3, split[0]);
Vector dir; Vector dir;
if (split[1].equals("vert") || split[1].equals("vertical")) {
Region region = session.getRegion();
int oldSize = region.getSize();
region.expand(new Vector(0, 128, 0));
region.expand(new Vector(0, -128, 0));
session.learnRegionChanges();
int newSize = region.getSize();
player.print("Region expanded " + (newSize - oldSize) + " blocks [top-to-bottom].");
return true;
}
int change = Integer.parseInt(split[1]); int change = Integer.parseInt(split[1]);
int reverseChange = 0;
if (split.length == 3) { if (split.length == 3) {
try {
reverseChange = Integer.parseInt(split[2]) * -1;
dir = getDirection(player, "me");
} catch (NumberFormatException e) {
dir = getDirection(player, split[2].toLowerCase()); dir = getDirection(player, split[2].toLowerCase());
}
} else if (split.length == 4) {
reverseChange = Integer.parseInt(split[2]) * -1;
dir = getDirection(player, split[3].toLowerCase());
} else { } else {
dir = getDirection(player, "me"); dir = getDirection(player, "me");
} }
@ -1293,6 +1302,9 @@ public class WorldEditController {
Region region = session.getRegion(); Region region = session.getRegion();
int oldSize = region.getSize(); int oldSize = region.getSize();
region.expand(dir.multiply(change)); region.expand(dir.multiply(change));
if (reverseChange != 0) {
region.expand(dir.multiply(reverseChange));
}
session.learnRegionChanges(); session.learnRegionChanges();
int newSize = region.getSize(); int newSize = region.getSize();
player.print("Region expanded " + (newSize - oldSize) + " blocks."); player.print("Region expanded " + (newSize - oldSize) + " blocks.");
@ -1301,11 +1313,20 @@ public class WorldEditController {
// Contract // Contract
} else if (split[0].equalsIgnoreCase("//contract")) { } else if (split[0].equalsIgnoreCase("//contract")) {
checkArgs(split, 1, 2, split[0]); checkArgs(split, 1, 3, split[0]);
Vector dir; Vector dir;
int change = Integer.parseInt(split[1]); int change = Integer.parseInt(split[1]);
int reverseChange = 0;
if (split.length == 3) { if (split.length == 3) {
try {
reverseChange = Integer.parseInt(split[2]) * -1;
dir = getDirection(player, "me");
} catch (NumberFormatException e) {
dir = getDirection(player, split[2].toLowerCase()); dir = getDirection(player, split[2].toLowerCase());
}
} else if (split.length == 4) {
reverseChange = Integer.parseInt(split[2]) * -1;
dir = getDirection(player, split[3].toLowerCase());
} else { } else {
dir = getDirection(player, "me"); dir = getDirection(player, "me");
} }
@ -1313,6 +1334,9 @@ public class WorldEditController {
Region region = session.getRegion(); Region region = session.getRegion();
int oldSize = region.getSize(); int oldSize = region.getSize();
region.contract(dir.multiply(change)); region.contract(dir.multiply(change));
if (reverseChange != 0) {
region.contract(dir.multiply(reverseChange));
}
session.learnRegionChanges(); session.learnRegionChanges();
int newSize = region.getSize(); int newSize = region.getSize();
player.print("Region contracted " + (oldSize - newSize) + " blocks."); player.print("Region contracted " + (oldSize - newSize) + " blocks.");
@ -1972,14 +1996,18 @@ public class WorldEditController {
if (command.equalsIgnoreCase("/pos1") if (command.equalsIgnoreCase("/pos1")
|| command.equalsIgnoreCase("/pos2") || command.equalsIgnoreCase("/pos2")
|| command.equalsIgnoreCase("/hpos1") || command.equalsIgnoreCase("/hpos1")
|| command.equalsIgnoreCase("/hpos2")) { || command.equalsIgnoreCase("/hpos2")
|| command.equalsIgnoreCase("/chunk")
|| command.equalsIgnoreCase("/expand")
|| command.equalsIgnoreCase("/contract")
|| command.equalsIgnoreCase("/shift")
|| command.equalsIgnoreCase("toggleeditwand")) {
return player.hasPermission(command) return player.hasPermission(command)
|| player.hasPermission("worldeditselect") || player.hasPermission("worldeditselect")
|| player.hasPermission("worldedit"); || player.hasPermission("worldedit");
} }
return player.hasPermission(command.replace("air", "")) return player.hasPermission("worldedit");
|| player.hasPermission("worldedit");
} }
/** /**