From 868ab5c6c40a3406b8fa2a1645755ccaa07ed608 Mon Sep 17 00:00:00 2001 From: CmdrKittens <52665651+CmdrKittens@users.noreply.github.com> Date: Tue, 9 Jul 2019 02:15:38 -0400 Subject: [PATCH] Treat armorstand/itemframe interaction as container (#1208) --- .../listeners/FactionsPlayerListener.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index a5b9c375..fd2d9a7b 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -18,7 +18,6 @@ import com.massivecraft.factions.zcore.gui.FactionGUI; import com.massivecraft.factions.zcore.persist.MemoryFPlayer; import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TextUtil; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -247,6 +246,22 @@ public class FactionsPlayerListener implements Listener { } } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEntityEvent event) { + Material material = null; + switch (event.getRightClicked().getType()) { + case ARMOR_STAND: + material = Material.ARMOR_STAND; + break; + case ITEM_FRAME: + material = Material.ITEM_FRAME; + break; + } + if (material != null && !playerCanUseItemHere(event.getPlayer(), event.getRightClicked().getLocation(), material, false)) { + event.setCancelled(true); + } + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { // only need to check right-clicks and physical as of MC 1.4+; good performance boost @@ -464,6 +479,8 @@ public class FactionsPlayerListener implements Listener { case GRINDSTONE: case SMOKER: case STONECUTTER: + case ARMOR_STAND: + case ITEM_FRAME: action = PermissableAction.CONTAINER; break; default: