From cba1927cc7ad7aba5068722389c8efbe7b680122 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Wed, 10 Aug 2022 10:22:19 +0200 Subject: [PATCH] Items no longer despawn on road when natural_mob_spawning = true and kill-road-items = false (#3764) * fix: handling of item despawning on road * chore: de-duplicate check * chore: check in PaperListener for consistency --- .../bukkit/listener/EntitySpawnListener.java | 12 ++++++------ .../plotsquared/bukkit/listener/PaperListener.java | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) 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 77d694379..841f52970 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java @@ -126,16 +126,16 @@ public class EntitySpawnListener implements Listener { Plot plot = location.getOwnedPlotAbs(); EntityType type = entity.getType(); if (plot == null) { + if (type == EntityType.DROPPED_ITEM) { + if (Settings.Enabled_Components.KILL_ROAD_ITEMS) { + event.setCancelled(true); + } + return; + } if (!area.isMobSpawning()) { if (type == EntityType.PLAYER) { return; } - if (type == EntityType.DROPPED_ITEM) { - if (Settings.Enabled_Components.KILL_ROAD_ITEMS) { - event.setCancelled(true); - } - return; - } if (type.isAlive()) { event.setCancelled(true); } 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 a2609fb23..9e3d9ba8e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -229,17 +229,17 @@ public class PaperListener implements Listener { Plot plot = location.getOwnedPlotAbs(); if (plot == null) { EntityType type = event.getType(); + // PreCreatureSpawnEvent **should** not be called for DROPPED_ITEM, just for the sake of consistency + if (type == EntityType.DROPPED_ITEM) { + if (Settings.Enabled_Components.KILL_ROAD_ITEMS) { + event.setCancelled(true); + } + return; + } if (!area.isMobSpawning()) { if (type == EntityType.PLAYER) { return; } - if (type == EntityType.DROPPED_ITEM) { - if (Settings.Enabled_Components.KILL_ROAD_ITEMS) { - event.setShouldAbortSpawn(true); - event.setCancelled(true); - } - return; - } if (type.isAlive()) { event.setShouldAbortSpawn(true); event.setCancelled(true);