From cdb44d48849d7111cc91911e13d1550d4555fd73 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 25 Nov 2023 20:30:48 +0000 Subject: [PATCH] fix: re-add default spawn option and disclude armour stands (#4240) - Fixes #4238 --- .../bukkit/listener/EntityEventListener.java | 8 ++++++-- .../plotsquared/bukkit/listener/PaperListener.java | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java index 6c786c79b..783eacd2b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java @@ -143,6 +143,10 @@ public class EntityEventListener implements Listener { if (area == null) { return; } + // Armour-stands are handled elsewhere and should not be handled by area-wide entity-spawn options + if (entity.getType() == EntityType.ARMOR_STAND) { + return; + } CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); switch (reason.toString()) { case "DISPENSE_EGG", "EGG", "OCELOT_BABY", "SPAWNER_EGG" -> { @@ -153,7 +157,7 @@ public class EntityEventListener implements Listener { } case "REINFORCEMENTS", "NATURAL", "MOUNT", "PATROL", "RAID", "SHEARED", "SILVERFISH_BLOCK", "ENDER_PEARL", "TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL", - "DUPLICATION", "FROZEN", "SPELL" -> { + "DUPLICATION", "FROZEN", "SPELL", "DEFAULT" -> { if (!area.isMobSpawning()) { event.setCancelled(true); return; @@ -166,7 +170,7 @@ public class EntityEventListener implements Listener { } } case "BUILD_IRONGOLEM", "BUILD_SNOWMAN", "BUILD_WITHER", "CUSTOM" -> { - if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) { + if (!area.isSpawnCustom()) { event.setCancelled(true); return; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 0e058e9a1..6bd528d3b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -124,7 +124,7 @@ public class PaperListener implements Listener { } Slime slime = event.getEntity(); - Block b = slime.getTargetBlock(4); + Block b = slime.getTargetBlockExact(4); if (b == null) { return; } @@ -166,12 +166,16 @@ public class PaperListener implements Listener { } Location location = BukkitUtil.adapt(event.getSpawnLocation()); PlotArea area = location.getPlotArea(); - if (!location.isPlotArea()) { + if (area == null) { return; } - //If entities are spawning... the chunk should be loaded? + // Armour-stands are handled elsewhere and should not be handled by area-wide entity-spawn options + if (event.getType() == EntityType.ARMOR_STAND) { + return; + } + // If entities are spawning... the chunk should be loaded? Entity[] entities = event.getSpawnLocation().getChunk().getEntities(); - if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) { + if (entities.length >= Settings.Chunk_Processor.MAX_ENTITIES) { event.setShouldAbortSpawn(true); event.setCancelled(true); return; @@ -200,7 +204,7 @@ public class PaperListener implements Listener { } } case "BUILD_IRONGOLEM", "BUILD_SNOWMAN", "BUILD_WITHER", "CUSTOM" -> { - if (!area.isSpawnCustom() && event.getType() != EntityType.ARMOR_STAND) { + if (!area.isSpawnCustom()) { event.setShouldAbortSpawn(true); event.setCancelled(true); return;