Fix issues with 94619e3f. Closes WORLDEDIT-2221.

This commit is contained in:
Wizjany 2012-11-22 13:28:36 -05:00
parent b2ff0fb2a2
commit aadfc30fbb
2 changed files with 21 additions and 13 deletions

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.commands; package com.sk89q.worldedit.commands;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
import java.util.Comparator; import java.util.Comparator;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
@ -30,11 +32,19 @@ import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.CommandsManager; import com.sk89q.minecraft.util.commands.CommandsManager;
import com.sk89q.minecraft.util.commands.Console; import com.sk89q.minecraft.util.commands.Console;
import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.minecraft.util.commands.Logging;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.EntityType;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.LocalWorld.KillFlags; import com.sk89q.worldedit.LocalWorld.KillFlags;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.patterns.*; import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.patterns.SingleBlockPattern;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
@ -368,19 +378,15 @@ public class UtilityCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
final int radius; int radius = config.butcherDefaultRadius;
if (args.argsLength() > 0) { if (args.argsLength() > 0) {
if (args.getString(0).equals("all")) { if (args.getString(0).equals("all")) {
radius = -1; radius = -1;
} } else {
else {
radius = Math.max(1, args.getInteger(0)); radius = Math.max(1, args.getInteger(0));
} }
} }
else{
radius = config.butcherDefaultRadius;
}
FlagContainer flags = new FlagContainer(player); FlagContainer flags = new FlagContainer(player);
flags.or(KillFlags.FRIENDLY , args.hasFlag('f')); flags.or(KillFlags.FRIENDLY , args.hasFlag('f'));
@ -400,11 +406,12 @@ public class UtilityCommands {
} }
} }
if (radius < 0) if (radius < 0) {
player.print("Killed " + killed + " mobs."); player.print("Killed " + killed + " mobs.");
else } else {
player.print("Killed " + killed + " mobs in a radius of " + radius + "."); player.print("Killed " + killed + " mobs in a radius of " + radius + ".");
} }
}
public class FlagContainer { public class FlagContainer {
private final LocalPlayer player; private final LocalPlayer player;
@ -496,6 +503,7 @@ public class UtilityCommands {
if (args.argsLength() == 0) { if (args.argsLength() == 0) {
SortedSet<String> commands = new TreeSet<String>(new Comparator<String>() { SortedSet<String> commands = new TreeSet<String>(new Comparator<String>() {
@Override
public int compare(String o1, String o2) { public int compare(String o1, String o2) {
final int ret = o1.replaceAll("/", "").compareToIgnoreCase(o2.replaceAll("/", "")); final int ret = o1.replaceAll("/", "").compareToIgnoreCase(o2.replaceAll("/", ""));
if (ret == 0) { if (ret == 0) {