Prevent armor items from being taken by the hologram

This commit is contained in:
Eric 2017-03-17 15:01:11 +01:00
parent d2b75295ca
commit bc13dd7a9d

View File

@ -44,6 +44,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.*; import org.bukkit.inventory.*;
@ -72,6 +73,16 @@ public class ShopInteractListener implements Listener {
this.worldGuard = plugin.getWorldGuard(); 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) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteractCreate(PlayerInteractEvent e) { public void onPlayerInteractCreate(PlayerInteractEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();