From 1f64c3383da14a25954f7c02e7ccb1a79354e620 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 1 Jan 2026 17:04:09 +0100 Subject: [PATCH] Fix HotbarKitListener Signed-off-by: Chaoscaot --- CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt | 5 +++-- .../src/de/steamwar/fightsystem/fight/HotbarKitListener.java | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt index 55d38a6a..5f4c873b 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt @@ -73,8 +73,8 @@ class InternalKit(id: EntityID): CompositeEntity(id) { this.rawInventory = rawInventory this.rawArmor = rawArmor this.inUse = false - } - }.also { it.setDefault() } + }.also { it.setDefault() } + } @JvmStatic fun getKitInUse(userId: Int, gamemode: String) = useDb { @@ -110,6 +110,7 @@ class InternalKit(id: EntityID): CompositeEntity(id) { fun setDefault() = useDb { find { PersonalKitTable.userId eq userID and (PersonalKitTable.gamemode eq gameMode) and (PersonalKitTable.inUse eq true) } + .filter { it.id.value != this@InternalKit.id.value } .forEach { it.inUse = false } inUse = true } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java index fa8e1dc3..afc735a2 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java @@ -34,6 +34,7 @@ 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.PlayerInventory; import java.util.HashSet; import java.util.Set; @@ -62,6 +63,7 @@ public class HotbarKitListener implements Listener { public void onInventoryClick(InventoryClickEvent event) { int slot = event.getSlot(); if (slot < 0 || slot >= HotbarKit.HOTBAR_SIZE) return; + if (!(event.getClickedInventory() instanceof PlayerInventory)) return; Player player = (Player) event.getWhoClicked(); click(player, slot, event);