diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index 161ff8a91..05e325450 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -1298,6 +1298,17 @@ public class PlayerEventListener implements Listener { //Allow all players to eat while also allowing the block place event to be fired return; } + // Process creature spawning of armor stands & end crystals here if spawned by the player in order to be able to + // reset the player's hand item if spawning needs to be cancelled. + if (type == Material.ARMOR_STAND || type == Material.END_CRYSTAL) { + Plot plot = location.getOwnedPlotAbs(); + if (BukkitEntityUtil.checkEntity(type == Material.ARMOR_STAND ? EntityType.ARMOR_STAND : EntityType.ENDER_CRYSTAL, + plot)) { + event.setCancelled(true); + break; + } + } + // Continue with normal place event checks if (type == Material.ARMOR_STAND) { location = BukkitUtil.adapt(block.getRelative(event.getBlockFace()).getLocation()); eventType = PlayerBlockEventType.PLACE_MISC; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java index cb0272f2d..5bb8988fa 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java @@ -354,13 +354,17 @@ public class BukkitEntityUtil { } public static boolean checkEntity(Entity entity, Plot plot) { + return checkEntity(entity.getType(), plot); + } + + public static boolean checkEntity(EntityType type, Plot plot) { if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea() .getFlagContainer().getFlagMap().isEmpty()) { return false; } final com.sk89q.worldedit.world.entity.EntityType entityType = - BukkitAdapter.adapt(entity.getType()); + BukkitAdapter.adapt(type); if (EntityCategories.PLAYER.contains(entityType)) { return false;