Skip to content

Commit f400f81

Browse files
Iaccidentallykhobbits
authored andcommitted
Add more functionality to the remove command. This now overlaps some functionality of the killall command, which should eventually be merged into this command and removed. new options: hostile, monsters, passive, animals, ambient, mobs, entities
1 parent 5d1ea4a commit f400f81

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

Essentials/src/com/earth2me/essentials/commands/Commandremove.java

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.bukkit.entity.*;
1111

1212
//Todo: Fix this up
13+
//Todo: now overlaps some functions of killall, which should be deprecated and removed once all functions are covered
1314
public class Commandremove extends EssentialsCommand
1415
{
1516
public Commandremove()
@@ -60,7 +61,6 @@ protected void run(final Server server, final User user, final String commandLab
6061
throw new NotEnoughArgumentsException(ee); //TODO: translate and list types
6162
}
6263
}
63-
6464
removeEntities(user.getSource(), world, toRemove, radius);
6565
}
6666

@@ -110,6 +110,7 @@ private void removeEntities(final CommandSource sender, final World world, final
110110
continue;
111111
}
112112
}
113+
//TODO: this would probably be better as a case statement instead of all the ifs
113114
if (toRemove == ToRemove.DROPS)
114115
{
115116
if (e instanceof Item)
@@ -174,6 +175,51 @@ else if (toRemove == ToRemove.ENDERCRYSTALS)
174175
removed++;
175176
}
176177
}
178+
else if (toRemove == ToRemove.AMBIENT)
179+
{
180+
if (e instanceof Flying)
181+
{
182+
e.remove();
183+
removed++;
184+
}
185+
}
186+
else if (toRemove == ToRemove.HOSTILE || toRemove == ToRemove.MONSTERS)
187+
{
188+
if (e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime)
189+
{
190+
e.remove();
191+
removed++;
192+
}
193+
}
194+
else if (toRemove == ToRemove.PASSIVE || toRemove == ToRemove.ANIMALS)
195+
{
196+
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob)
197+
{
198+
e.remove();
199+
removed++;
200+
}
201+
}
202+
else if (toRemove == ToRemove.MOBS)
203+
{
204+
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob
205+
|| e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime)
206+
{
207+
e.remove();
208+
removed++;
209+
}
210+
}
211+
else if (toRemove == ToRemove.ENTITIES)
212+
{
213+
if (e instanceof Entity)
214+
{
215+
if (e instanceof HumanEntity)
216+
{
217+
continue;
218+
}
219+
e.remove();
220+
removed++;
221+
}
222+
}
177223
}
178224
}
179225
sender.sendMessage(_("removed", removed));
@@ -189,6 +235,13 @@ private enum ToRemove
189235
XP,
190236
PAINTINGS,
191237
ITEMFRAMES,
192-
ENDERCRYSTALS
238+
ENDERCRYSTALS,
239+
HOSTILE,
240+
MONSTERS,
241+
PASSIVE,
242+
ANIMALS,
243+
AMBIENT,
244+
MOBS,
245+
ENTITIES
193246
}
194247
}

Essentials/src/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ commands:
304304
aliases: [formula,eformula,method,emethod,erecipe,recipes,erecipes]
305305
remove:
306306
description: Removes entities in your world.
307-
usage: /<command> <drops|arrows|boats|minecarts|xp|paintings|itemframes|endercrystals> [radius] [world]
307+
usage: /<command> <drops|arrows|boats|minecarts|xp|paintings|itemframes|endercrystals|hostile|monsters|passive|animals|ambient|mobs|entities> [radius] [world]
308308
aliases: [eremove]
309309
repair:
310310
description: Repairs the durability of one or all items.

0 commit comments

Comments
 (0)