Replaced an if-else tree in /rement by an equivalent switch.

This commit is contained in:
TomyLobo 2013-07-09 18:37:48 +02:00
parent b710f919d5
commit 34093884bc

View File

@ -1004,59 +1004,80 @@ public class BukkitWorld extends LocalWorld {
continue; continue;
} }
if (type == EntityType.ALL) { switch (type) {
case ALL:
if (ent instanceof Projectile || ent instanceof Boat || ent instanceof Item if (ent instanceof Projectile || ent instanceof Boat || ent instanceof Item
|| ent instanceof FallingBlock || ent instanceof Minecart || ent instanceof Hanging || ent instanceof FallingBlock || ent instanceof Minecart || ent instanceof Hanging
|| ent instanceof TNTPrimed || ent instanceof ExperienceOrb) { || ent instanceof TNTPrimed || ent instanceof ExperienceOrb) {
ent.remove(); ent.remove();
num++; num++;
} }
} else if (type == EntityType.PROJECTILES || type == EntityType.ARROWS) { break;
case PROJECTILES:
case ARROWS:
if (ent instanceof Projectile) { if (ent instanceof Projectile) {
// covers: arrow, egg, enderpearl, fireball, fish, snowball, throwpotion, thrownexpbottle // covers: arrow, egg, enderpearl, fireball, fish, snowball, throwpotion, thrownexpbottle
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.BOATS) { break;
case BOATS:
if (ent instanceof Boat) { if (ent instanceof Boat) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.ITEMS) { break;
case ITEMS:
if (ent instanceof Item) { if (ent instanceof Item) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.FALLING_BLOCKS) { break;
case FALLING_BLOCKS:
if (ent instanceof FallingBlock) { if (ent instanceof FallingBlock) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.MINECARTS) { break;
case MINECARTS:
if (ent instanceof Minecart) { if (ent instanceof Minecart) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.PAINTINGS) { break;
case PAINTINGS:
if (ent instanceof Painting) { if (ent instanceof Painting) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.ITEM_FRAMES) { break;
case ITEM_FRAMES:
if (ent instanceof ItemFrame) { if (ent instanceof ItemFrame) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.TNT) { break;
case TNT:
if (ent instanceof TNTPrimed || ent.getType() == tntMinecartType) { if (ent instanceof TNTPrimed || ent.getType() == tntMinecartType) {
ent.remove(); ent.remove();
++num; ++num;
} }
} else if (type == EntityType.XP_ORBS) { break;
case XP_ORBS:
if (ent instanceof ExperienceOrb) { if (ent instanceof ExperienceOrb) {
ent.remove(); ent.remove();
++num; ++num;
} }
break;
} }
} }