diff options
author | KHobbits <rob@khobbits.co.uk> | 2014-02-09 22:26:54 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2014-02-09 22:26:54 +0000 |
commit | fa765d3077852cd1093cd8dae16a6f7e4fe141b4 (patch) | |
tree | ffb9b9683d7245bbbcec5ab0e4d71612513ca1ca | |
parent | 9bc8f287a4aa63a282aeec2dd3be8fcd88ed10f1 (diff) | |
download | Essentials-fa765d3077852cd1093cd8dae16a6f7e4fe141b4.tar Essentials-fa765d3077852cd1093cd8dae16a6f7e4fe141b4.tar.gz Essentials-fa765d3077852cd1093cd8dae16a6f7e4fe141b4.tar.lz Essentials-fa765d3077852cd1093cd8dae16a6f7e4fe141b4.tar.xz Essentials-fa765d3077852cd1093cd8dae16a6f7e4fe141b4.zip |
Fix world argument to ignore radius, and allow for skipping radius param in syntax.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandremove.java | 43 | ||||
-rw-r--r-- | Essentials/src/plugin.yml | 2 |
2 files changed, 26 insertions, 19 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java index cafd22ba8..9fa946260 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java @@ -20,7 +20,7 @@ public class Commandremove extends EssentialsCommand { super("remove"); } - + @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { @@ -38,17 +38,19 @@ public class Commandremove extends EssentialsCommand } catch (NumberFormatException e) { - throw new Exception(_("numberRequired"), e); + world = ess.getWorld(args[1]); } } if (args.length >= 3) { + // This is to prevent breaking the old syntax + radius = 0; world = ess.getWorld(args[2]); } parseCommand(server, user.getSource(), args, world, radius); - + } - + @Override protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { @@ -59,12 +61,17 @@ public class Commandremove extends EssentialsCommand World world = ess.getWorld(args[1]); parseCommand(server, sender, args, world, 0); } - + private void parseCommand(Server server, CommandSource sender, String[] args, World world, int radius) throws Exception { List<String> types = new ArrayList<String>(); List<String> customTypes = new ArrayList<String>(); - + + if (world == null) + { + throw new Exception(_("invalidWorld")); + } + if (args[0].contentEquals("*") || args[0].contentEquals("all")) { types.add(0, "ALL"); @@ -95,7 +102,7 @@ public class Commandremove extends EssentialsCommand } removeHandler(sender, types, customTypes, world, radius); } - + private void removeHandler(CommandSource sender, List<String> types, List<String> customTypes, World world, int radius) { int removed = 0; @@ -103,17 +110,17 @@ public class Commandremove extends EssentialsCommand { radius *= radius; } - + ArrayList<ToRemove> removeTypes = new ArrayList<ToRemove>(); ArrayList<Mob> customRemoveTypes = new ArrayList<Mob>(); - + for (String s : types) { removeTypes.add(ToRemove.valueOf(s)); } - + boolean warnUser = false; - + for (String s : customTypes) { Mob mobType = Mob.fromName(s); @@ -126,12 +133,12 @@ public class Commandremove extends EssentialsCommand customRemoveTypes.add(mobType); } } - + if (warnUser) { sender.sendMessage(_("invalidMob")); } - + for (Chunk chunk : world.getLoadedChunks()) { for (Entity e : chunk.getEntities()) @@ -147,10 +154,10 @@ public class Commandremove extends EssentialsCommand { continue; } - + for (ToRemove toRemove : removeTypes) { - + if (e instanceof Tameable && ((Tameable)e).isTamed()) { if (toRemove == ToRemove.TAMED) @@ -163,7 +170,7 @@ public class Commandremove extends EssentialsCommand continue; } } - + switch (toRemove) { case DROPS: @@ -278,8 +285,8 @@ public class Commandremove extends EssentialsCommand } sender.sendMessage(_("removed", removed)); } - - + + private enum ToRemove { DROPS, diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index bb40080d9..e26b0673c 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -300,7 +300,7 @@ commands: aliases: [formula,eformula,method,emethod,erecipe,recipes,erecipes] remove: description: Removes entities in your world. - usage: /<command> <all|tamed|drops|arrows|boats|minecarts|xp|paintings|itemframes|endercrystals|monsters|animals|ambient|mobs|[mobType]> [radius] [world] + usage: /<command> <all|tamed|drops|arrows|boats|minecarts|xp|paintings|itemframes|endercrystals|monsters|animals|ambient|mobs|[mobType]> [radius|world] aliases: [eremove,butcher,ebutcher,killall,ekillall,mobkill,emobkill] repair: description: Repairs the durability of one or all items. |