From bc13dd7a9d1cc2cbadac8a9bc706ed6949893931 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 17 Mar 2017 15:01:11 +0100 Subject: [PATCH] Prevent armor items from being taken by the hologram --- .../shopchest/listeners/ShopInteractListener.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java index dfa2946..8e5fcb0 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java @@ -44,6 +44,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerArmorStandManipulateEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.*; @@ -72,6 +73,16 @@ public class ShopInteractListener implements Listener { this.worldGuard = plugin.getWorldGuard(); } + @EventHandler(ignoreCancelled = true) + public void onPlayerManipulateArmorStand(PlayerArmorStandManipulateEvent e) { + // When clicking an armor stand with an armor item, the armor stand will take it. + // As a hologram consists of armor stands, they would also take the item. + ArmorStand armorStand = e.getRightClicked(); + if (Hologram.isPartOfHologram(armorStand)) { + e.setCancelled(true); + } + } + @EventHandler(priority = EventPriority.HIGH) public void onPlayerInteractCreate(PlayerInteractEvent e) { Player p = e.getPlayer();