Skip to content

Commit 82be754

Browse files
Iaccidentallykhobbits
authored andcommitted
Tidy up Commandremove a bit, thanks to Evonuts
1 parent f400f81 commit 82be754

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

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

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -110,115 +110,114 @@ 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
114-
if (toRemove == ToRemove.DROPS)
113+
if (e instanceof Tameable)
115114
{
115+
if (((Tameable)e).isTamed())
116+
{
117+
continue;
118+
}
119+
}
120+
switch (toRemove)
121+
{
122+
case DROPS:
116123
if (e instanceof Item)
117124
{
118125
e.remove();
119126
removed++;
120127
}
121-
}
122-
else if (toRemove == ToRemove.ARROWS)
123-
{
128+
;
129+
break;
130+
case ARROWS:
124131
if (e instanceof Projectile)
125132
{
126133
e.remove();
127134
removed++;
128135
}
129-
}
130-
else if (toRemove == ToRemove.BOATS)
131-
{
136+
break;
137+
case BOATS:
132138
if (e instanceof Boat)
133139
{
134140
e.remove();
135141
removed++;
136142
}
137-
}
138-
else if (toRemove == ToRemove.MINECARTS)
139-
{
143+
break;
144+
case MINECARTS:
140145
if (e instanceof Minecart)
141146
{
142147
e.remove();
143148
removed++;
144149
}
145-
}
146-
else if (toRemove == ToRemove.XP)
147-
{
150+
break;
151+
case XP:
148152
if (e instanceof ExperienceOrb)
149153
{
150154
e.remove();
151155
removed++;
152156
}
153-
}
154-
else if (toRemove == ToRemove.PAINTINGS)
155-
{
157+
break;
158+
case PAINTINGS:
156159
if (e instanceof Painting)
157160
{
158161
e.remove();
159162
removed++;
160163
}
161-
}
162-
else if (toRemove == ToRemove.ITEMFRAMES)
163-
{
164+
break;
165+
case ITEMFRAMES:
164166
if (e instanceof ItemFrame)
165167
{
166168
e.remove();
167169
removed++;
168170
}
169-
}
170-
else if (toRemove == ToRemove.ENDERCRYSTALS)
171-
{
171+
break;
172+
case ENDERCRYSTALS:
172173
if (e instanceof EnderCrystal)
173174
{
174175
e.remove();
175176
removed++;
176177
}
177-
}
178-
else if (toRemove == ToRemove.AMBIENT)
179-
{
178+
break;
179+
case AMBIENT:
180180
if (e instanceof Flying)
181181
{
182182
e.remove();
183183
removed++;
184184
}
185-
}
186-
else if (toRemove == ToRemove.HOSTILE || toRemove == ToRemove.MONSTERS)
187-
{
185+
break;
186+
case HOSTILE:
187+
case MONSTERS:
188188
if (e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime)
189189
{
190190
e.remove();
191191
removed++;
192192
}
193-
}
194-
else if (toRemove == ToRemove.PASSIVE || toRemove == ToRemove.ANIMALS)
195-
{
193+
break;
194+
case PASSIVE:
195+
case ANIMALS:
196196
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob)
197197
{
198198
e.remove();
199199
removed++;
200200
}
201-
}
202-
else if (toRemove == ToRemove.MOBS)
203-
{
201+
break;
202+
case MOBS:
204203
if (e instanceof Animals || e instanceof NPC || e instanceof Snowman || e instanceof WaterMob
205204
|| e instanceof Monster || e instanceof ComplexLivingEntity || e instanceof Flying || e instanceof Slime)
206205
{
207206
e.remove();
208207
removed++;
209208
}
210-
}
211-
else if (toRemove == ToRemove.ENTITIES)
212-
{
209+
break;
210+
case ENTITIES:
213211
if (e instanceof Entity)
214212
{
215-
if (e instanceof HumanEntity)
213+
if (e instanceof HumanEntity)
216214
{
217215
continue;
218216
}
219217
e.remove();
220218
removed++;
221219
}
220+
break;
222221
}
223222
}
224223
}

0 commit comments

Comments
 (0)