From e4a6bd0ca58ec6e976cdbaca714a272259687e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Tue, 7 Apr 2020 20:56:43 +0200 Subject: [PATCH] Don't try to remove players. Fixes #2742. --- .../bukkit/listeners/EntitySpawnListener.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java index 0c5ce4fd3..5fade4edb 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java @@ -39,7 +39,7 @@ public class EntitySpawnListener implements Listener { private static boolean hasPlotArea = false; private static String areaName = null; - public static void testNether(Entity entity) { + public static void testNether(final Entity entity) { @NotNull World world = entity.getWorld(); if (world.getEnvironment() != World.Environment.NETHER && world.getEnvironment() != World.Environment.THE_END) { @@ -48,15 +48,15 @@ public class EntitySpawnListener implements Listener { test(entity); } - public static void testCreate(Entity entity) { + public static void testCreate(final Entity entity) { @NotNull World world = entity.getWorld(); - if (areaName == world.getName()) { - } else { + if (!areaName.equals(world.getName())) { areaName = world.getName(); hasPlotArea = PlotSquared.get().hasPlotArea(areaName); } - if (!hasPlotArea) + if (!hasPlotArea) { return; + } test(entity); } @@ -76,15 +76,21 @@ public class EntitySpawnListener implements Listener { if (!world.getName().equalsIgnoreCase(originWorld + "_the_end")) { try { ignoreTP = true; - PaperLib.teleportAsync(entity,origin); + PaperLib.teleportAsync(entity, origin); } finally { ignoreTP = false; } + if (entity.getType() == EntityType.PLAYER) { + return; + } if (entity.getLocation().getWorld().equals(world)) { entity.remove(); } } } else { + if (entity.getType() == EntityType.PLAYER) { + return; + } entity.remove(); } } @@ -136,7 +142,7 @@ public class EntitySpawnListener implements Listener { @EventHandler public void onChunkLoad(ChunkLoadEvent event) { @NotNull Chunk chunk = event.getChunk(); - for (Entity entity : chunk.getEntities()) { + for (final Entity entity : chunk.getEntities()) { testCreate(entity); } }