- Add break statements to switches to prevent bleed from normal spawning to breeding
 - Separate misc spawning from mob spawning
This commit is contained in:
dordsor21 2020-07-28 13:56:37 +01:00
parent ab121c7eee
commit e2f9b4245b
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
3 changed files with 10 additions and 11 deletions

View File

@ -146,6 +146,7 @@ public class EntityEventListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break;
case "BREEDING": case "BREEDING":
if (!area.isSpawnBreeding()) { if (!area.isSpawnBreeding()) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -58,12 +58,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
@SuppressWarnings("unused")
public class EntitySpawnListener implements Listener { public class EntitySpawnListener implements Listener {
private final static String KEY = "P2"; private final static String KEY = "P2";
private static boolean ignoreTP = false; private static boolean ignoreTP = false;
private static boolean hasPlotArea = false;
private static String areaName = null;
public static void testNether(final Entity entity) { public static void testNether(final Entity entity) {
@NotNull World world = entity.getWorld(); @NotNull World world = entity.getWorld();
@ -76,12 +75,7 @@ public class EntitySpawnListener implements Listener {
public static void testCreate(final Entity entity) { public static void testCreate(final Entity entity) {
@NotNull World world = entity.getWorld(); @NotNull World world = entity.getWorld();
if (areaName == world.getName()) { if (!PlotSquared.get().hasPlotArea(entity.getWorld().getName())) {
} else {
areaName = world.getName();
hasPlotArea = PlotSquared.get().hasPlotArea(areaName);
}
if (!hasPlotArea) {
return; return;
} }
test(entity); test(entity);
@ -134,21 +128,24 @@ public class EntitySpawnListener implements Listener {
} }
Plot plot = location.getOwnedPlotAbs(); Plot plot = location.getOwnedPlotAbs();
if (plot == null) { if (plot == null) {
EntityType type = entity.getType();
if (!area.isMobSpawning()) { if (!area.isMobSpawning()) {
EntityType type = entity.getType();
switch (type) { switch (type) {
case DROPPED_ITEM: case DROPPED_ITEM:
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) { if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
event.setCancelled(true); event.setCancelled(true);
break; return;
} }
case PLAYER: case PLAYER:
return; return;
} }
if (type.isAlive() || !area.isMiscSpawnUnowned()) { if (type.isAlive()) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
if (!area.isMiscSpawnUnowned() && !type.isAlive()) {
event.setCancelled(true);
}
return; return;
} }
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {

View File

@ -193,6 +193,7 @@ public class PaperListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
break;
case "BREEDING": case "BREEDING":
if (!area.isSpawnBreeding()) { if (!area.isSpawnBreeding()) {
event.setShouldAbortSpawn(true); event.setShouldAbortSpawn(true);