From e2f9b4245b9f7168fc38d9cb10cd05efcb42fe05 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 28 Jul 2020 13:56:37 +0100 Subject: [PATCH] Fixes https://issues.intellectualsites.com/issue/PS-81 - Add break statements to switches to prevent bleed from normal spawning to breeding - Separate misc spawning from mob spawning --- .../bukkit/listener/EntityEventListener.java | 1 + .../bukkit/listener/EntitySpawnListener.java | 19 ++++++++----------- .../bukkit/listener/PaperListener.java | 1 + 3 files changed, 10 insertions(+), 11 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 5bfb26a56..342d4e6f0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java @@ -146,6 +146,7 @@ public class EntityEventListener implements Listener { event.setCancelled(true); return; } + break; case "BREEDING": if (!area.isSpawnBreeding()) { event.setCancelled(true); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java index 4b80909e7..08a0d12ff 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java @@ -58,12 +58,11 @@ import org.jetbrains.annotations.NotNull; import java.util.List; +@SuppressWarnings("unused") public class EntitySpawnListener implements Listener { private final static String KEY = "P2"; private static boolean ignoreTP = false; - private static boolean hasPlotArea = false; - private static String areaName = null; public static void testNether(final Entity entity) { @NotNull World world = entity.getWorld(); @@ -76,12 +75,7 @@ public class EntitySpawnListener implements Listener { public static void testCreate(final Entity entity) { @NotNull World world = entity.getWorld(); - if (areaName == world.getName()) { - } else { - areaName = world.getName(); - hasPlotArea = PlotSquared.get().hasPlotArea(areaName); - } - if (!hasPlotArea) { + if (!PlotSquared.get().hasPlotArea(entity.getWorld().getName())) { return; } test(entity); @@ -134,21 +128,24 @@ public class EntitySpawnListener implements Listener { } Plot plot = location.getOwnedPlotAbs(); if (plot == null) { + EntityType type = entity.getType(); if (!area.isMobSpawning()) { - EntityType type = entity.getType(); switch (type) { case DROPPED_ITEM: if (Settings.Enabled_Components.KILL_ROAD_ITEMS) { event.setCancelled(true); - break; + return; } case PLAYER: return; } - if (type.isAlive() || !area.isMiscSpawnUnowned()) { + if (type.isAlive()) { event.setCancelled(true); } } + if (!area.isMiscSpawnUnowned() && !type.isAlive()) { + event.setCancelled(true); + } return; } if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { 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 a512189f7..e3995d9df 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -193,6 +193,7 @@ public class PaperListener implements Listener { event.setCancelled(true); return; } + break; case "BREEDING": if (!area.isSpawnBreeding()) { event.setShouldAbortSpawn(true);