From 1de56fcf6ad59785c811cbcb23a10ced1e833cec Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 25 Mar 2017 13:24:05 +0100 Subject: [PATCH] Protect holograms from damage --- .../shopchest/listeners/ChestProtectListener.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java index c49f762..6accaa6 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java @@ -9,6 +9,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LocalizedMessage; +import de.epiceric.shopchest.nms.Hologram; import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.utils.Permissions; import de.epiceric.shopchest.utils.ShopUtils; @@ -20,12 +21,14 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; @@ -192,6 +195,15 @@ public class ChestProtectListener implements Listener { } } + @EventHandler(ignoreCancelled = true) + public void onHologramDamage(EntityDamageEvent e) { + if (e.getEntity() instanceof ArmorStand) { + if (Hologram.isPartOfHologram((ArmorStand) e.getEntity())) { + e.setCancelled(true); + } + } + } + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onItemMove(InventoryMoveItemEvent e) { if (plugin.getShopChestConfig().hopper_protection) {