From 7e8ba9a256029e6238ef7ce2e909e2d02eecd49b Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sun, 18 May 2014 14:17:55 +0100 Subject: Exempt named mobs by default from /remove Named mobs can be removed using /remove named Killing all mobs now requires /remove all,tamed,named --- .../essentials/commands/Commandremove.java | 34 ++++++++++++++++------ Essentials/src/plugin.yml | 2 +- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java index a77b0b863..ef9d3c6af 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java @@ -158,21 +158,36 @@ public class Commandremove extends EssentialsCommand for (ToRemove toRemove : removeTypes) { - if (e instanceof Tameable && ((Tameable)e).isTamed()) + // We should skip any TAMED animals unless we are specifially targetting them. + if (e instanceof Tameable && ((Tameable)e).isTamed() + && !removeTypes.contains(ToRemove.TAMED)) { - if (toRemove == ToRemove.TAMED) + continue; + } + + // We should skip any NAMED animals unless we are specifially targetting them. + if (e instanceof LivingEntity && ((LivingEntity)e).getCustomName() != null + && !removeTypes.contains(ToRemove.NAMED)) + { + continue; + } + + switch (toRemove) + { + case TAMED: + if (e instanceof Tameable && ((Tameable)e).isTamed()) { e.remove(); removed++; } - else + break; + case NAMED: + if (e instanceof LivingEntity && ((LivingEntity)e).getCustomName() != null) { - continue; + e.remove(); + removed++; } - } - - switch (toRemove) - { + break; case DROPS: if (e instanceof Item) { @@ -305,6 +320,7 @@ public class Commandremove extends EssentialsCommand ENTITIES, ALL, CUSTOM, - TAMED + TAMED, + NAMED } } \ No newline at end of file diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index af056c15a..23d0bd17a 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -304,7 +304,7 @@ commands: aliases: [formula,eformula,method,emethod,erecipe,recipes,erecipes] remove: description: Removes entities in your world. - usage: / [radius|world] + usage: / [radius|world] aliases: [eremove,butcher,ebutcher,killall,ekillall,mobkill,emobkill] repair: description: Repairs the durability of one or all items. -- cgit v1.2.3