diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java index 5bc1d844..6567fe87 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java @@ -34,6 +34,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; @@ -117,5 +118,22 @@ public class HotbarKit extends Kit { ((HotbarKit)activeKit).onClicks[slot].accept(player); } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event) { + int slot = event.getSlot(); + if (slot < 0 || slot >= HOTBAR_SIZE) return; + + Player player = (Player) event.getWhoClicked(); + Kit activeKit = activeKits.get(player); + if(!(activeKit instanceof HotbarKit) || PersonalKitCreator.inKitCreator(player) || activeKit.getInventory()[slot] == null) + return; + + event.setCancelled(true); + if(!clicked.add(player)) + return; + + ((HotbarKit)activeKit).onClicks[slot].accept(player); + } } }