diff --git a/changelog.md b/changelog.md index 18446fd..dd7980b 100644 --- a/changelog.md +++ b/changelog.md @@ -24,6 +24,7 @@ These changes will (most likely) be included in the next version. - Mobs now correctly take damage from player-made iron golems. - Cat and parrot pets now also sit when their owner joins an arena (although parrots perching on players' shoulders will still follow them into the arena). - Pig zombies are now angry immediately after they spawn as they should be. +- Vexes summoned by evokers are now kept track of, so they count towards `clear-wave-before-next`, and they are properly removed at arena end. - Support for denoting potion effects by magic number IDs has been dropped. This means that if your config-file has any such magic numbers in it, MobArena will no longer successfully parse them and will throw an error on startup. - Support for auto-respawning has been dropped. The hacky way it was implemented is not officially supported by the Bukkit API and is highly discouraged because it is very buggy. diff --git a/src/main/java/com/garbagemule/MobArena/ArenaListener.java b/src/main/java/com/garbagemule/MobArena/ArenaListener.java index bc9f989..d6bb75b 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaListener.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaListener.java @@ -402,22 +402,55 @@ public class ArenaListener return; } - if (event.getSpawnReason() != SpawnReason.CUSTOM) { - if (event.getSpawnReason() == SpawnReason.BUILD_IRONGOLEM || event.getSpawnReason() == SpawnReason.BUILD_SNOWMAN) { - monsters.addGolem(event.getEntity()); - } - else { - event.setCancelled(true); - return; - } + if (!arena.isRunning()) { + // Just block everything if we're not running + event.setCancelled(true); + return; } - LivingEntity entity = event.getEntity(); - if (arena.isRunning() && entity instanceof Slime) - monsters.addMonster(entity); + SpawnReason reason = event.getSpawnReason(); - // If running == true, setCancelled(false), and vice versa. - event.setCancelled(!arena.isRunning()); + // Allow player-made iron golems and snowmen + if (reason == SpawnReason.BUILD_IRONGOLEM || reason == SpawnReason.BUILD_SNOWMAN) { + event.setCancelled(false); + monsters.addGolem(event.getEntity()); + return; + } + + /* + * We normally want to block all "default" spawns, because this + * reason means MobArena didn't trigger the event. However, we + * make an exception for certain mobs that spawn as results of + * other entities spawning them, e.g. when Evokers summon Vexes. + */ + if (reason == SpawnReason.DEFAULT) { + if (event.getEntityType() == EntityType.VEX) { + event.setCancelled(false); + monsters.addMonster(event.getEntity()); + } else { + event.setCancelled(true); + } + return; + } + + // If not custom, we probably don't want it, so get rid of it + if (reason != SpawnReason.CUSTOM) { + event.setCancelled(true); + return; + } + + // Otherwise, we probably want it, so uncancel just in case + event.setCancelled(false); + + /* + * Because MACreature works with the Creature interface rather + * than the Mob interface, it doesn't catch Slimes and Magma + * Cubes, so we catch them here. + */ + LivingEntity entity = event.getEntity(); + if (entity instanceof Slime) { + monsters.addMonster(entity); + } } public void onEntityExplode(EntityExplodeEvent event) {