Cleanup and a few bugfixes

This commit is contained in:
Wizjany
2011-09-24 15:24:10 -04:00
parent a2e23fedf7
commit b5b55a2775
30 changed files with 170 additions and 191 deletions

View File

@ -49,8 +49,8 @@ public class ChunkCommands {
throws WorldEditException {
Vector pos = player.getBlockIn();
int chunkX = (int)Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int)Math.floor(pos.getBlockZ() / 16.0);
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
String folder1 = Integer.toString(WorldEdit.divisorMod(chunkX, 64), 36);
String folder2 = Integer.toString(WorldEdit.divisorMod(chunkZ, 64), 36);
@ -159,7 +159,10 @@ 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 {

View File

@ -61,7 +61,7 @@ public class RegionCommands {
if (pattern instanceof SingleBlockPattern) {
affected = editSession.setBlocks(session.getSelection(player.getWorld()),
((SingleBlockPattern)pattern).getBlock());
((SingleBlockPattern) pattern).getBlock());
} else {
affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
}
@ -96,7 +96,7 @@ public class RegionCommands {
int affected = 0;
if (to instanceof SingleBlockPattern) {
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from,
((SingleBlockPattern)to).getBlock());
((SingleBlockPattern) to).getBlock());
} else {
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
}
@ -123,7 +123,7 @@ public class RegionCommands {
int affected = 0;
if (pat instanceof SingleBlockPattern) {
affected = editSession.overlayCuboidBlocks(region,
((SingleBlockPattern)pat).getBlock());
((SingleBlockPattern) pat).getBlock());
} else {
affected = editSession.overlayCuboidBlocks(region, pat);
}

View File

@ -45,14 +45,19 @@ public class ScriptingCommands {
public static void execute(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
// @TODO: Check for worldedit.scripting.execute.<script> permission
String[] scriptArgs = args.getSlice(1);
String name = args.getString(0);
session.setLastScript(args.getString(0));
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
player.printError("You don't have permission to use that script.");
return;
}
session.setLastScript(name);
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
File f = we.getSafeOpenFile(player, dir, args.getString(0), "js",
File f = we.getSafeOpenFile(player, dir, name, "js",
new String[] {"js"});
we.runScript(player, f, scriptArgs);
@ -70,10 +75,14 @@ public class ScriptingCommands {
public static void executeLast(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
// @TODO: Check for worldedit.scripting.execute.<script> permission
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;

View File

@ -350,16 +350,14 @@ public class SelectionCommands {
reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player, "me");
} catch (NumberFormatException e) {
dir = we.getDirection(player,
args.getString(1).toLowerCase());
dir = we.getDirection(player, args.getString(1).toLowerCase());
}
break;
case 3:
// Both reverse amount and direction
reverseChange = args.getInteger(1) * -1;
dir = we.getDirection(player,
args.getString(2).toLowerCase());
dir = we.getDirection(player, args.getString(2).toLowerCase());
break;
default:
dir = we.getDirection(player, "me");
@ -398,8 +396,7 @@ public class SelectionCommands {
int change = args.getInteger(0);
if (args.argsLength() == 2) {
dir = we.getDirection(player,
args.getString(1).toLowerCase());
dir = we.getDirection(player, args.getString(1).toLowerCase());
} else {
dir = we.getDirection(player, "me");
}

View File

@ -60,7 +60,7 @@ public class UtilityCommands {
int affected = 0;
if (pattern instanceof SingleBlockPattern) {
affected = editSession.fillXZ(pos,
((SingleBlockPattern)pattern).getBlock(),
((SingleBlockPattern) pattern).getBlock(),
radius, depth, false);
} else {
affected = editSession.fillXZ(pos, pattern, radius, depth, false);
@ -90,7 +90,7 @@ public class UtilityCommands {
int affected = 0;
if (pattern instanceof SingleBlockPattern) {
affected = editSession.fillXZ(pos,
((SingleBlockPattern)pattern).getBlock(),
((SingleBlockPattern) pattern).getBlock(),
radius, depth, true);
} else {
affected = editSession.fillXZ(pos, pattern, radius, depth, true);
@ -197,8 +197,7 @@ public class UtilityCommands {
we.checkMaxRadius(size);
int height = args.argsLength() > 1 ? Math.min(128, args.getInteger(1) + 2) : 128;
int affected = editSession.removeBelow(
session.getPlacementPosition(player), size, height);
int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
player.print(affected + " block(s) have been removed.");
}
@ -219,8 +218,7 @@ public class UtilityCommands {
int size = Math.max(1, args.getInteger(1, 50));
we.checkMaxRadius(size);
int affected = editSession.removeNear(
session.getPlacementPosition(player), block.getType(), size);
int affected = editSession.removeNear(session.getPlacementPosition(player), block.getType(), size);
player.print(affected + " block(s) have been removed.");
}
@ -340,8 +338,7 @@ public class UtilityCommands {
: defaultRadius;
we.checkMaxRadius(size);
int affected = editSession.removeNear(
session.getPlacementPosition(player), 51, size);
int affected = editSession.removeNear(session.getPlacementPosition(player), 51, size);
player.print(affected + " block(s) have been removed.");
}
@ -359,8 +356,7 @@ public class UtilityCommands {
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
int radius = args.argsLength() > 0 ?
Math.max(1, args.getInteger(0)) : -1;
int radius = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : -1;
Vector origin = session.getPlacementPosition(player);
int killed = player.getWorld().killMobs(origin, radius, args.hasFlag('p'));