From 6400c960a9df5e563d8b3796ac29888781aed484 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 30 Oct 2021 14:32:02 +0200 Subject: [PATCH] Only allow TNT transfers to inventories Signed-off-by: Lixfel --- .../listener/InFightInventory.java | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java index 894a497..e74c13a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java @@ -29,8 +29,6 @@ import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; public class InFightInventory implements Listener { @@ -40,22 +38,12 @@ public class InFightInventory implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent event) { - Inventory clicked = event.getClickedInventory(); - if(event.getClick().isShiftClick()){ - ItemStack clickedOn = event.getCurrentItem(); + InventoryType top = event.getView().getTopInventory().getType(); + if(top == InventoryType.CRAFTING) + return; - if( - clickedOn != null && - event.getView().getTopInventory().getType() != InventoryType.CRAFTING && - clicked == event.getWhoClicked().getInventory()) - event.setCancelled(true); - }else if ( - clicked != event.getWhoClicked().getInventory() && - clicked != null && - clicked.getType() != InventoryType.PLAYER && - event.getCursor() != null && - event.getCursor().getType() != Material.AIR) - event.setCancelled(true); + if ((event.getCursor() != null && event.getCursor().getType() != Material.TNT) || (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.TNT)) + event.setCancelled(true); // Deny if transferred item is not TNT } @EventHandler