From 140ee8ef3e86151f7bc1da95b6a5fbd8a311538d Mon Sep 17 00:00:00 2001 From: TDSTOS Date: Sun, 12 Apr 2026 05:45:04 +0200 Subject: [PATCH] Exclude kit items from drops on death Prevent players from dropping kit-owned items when they die by filtering out kit items before dropping inventory contents. Added KitManager.isKitItem(player, item) which checks the player's selected kit and compares against the kit's cached items (using isSimilar). Also added the ItemStack import required for the new method. --- .../club/mcscrims/speedhg/game/GameManager.kt | 8 +++++--- .../kotlin/club/mcscrims/speedhg/kit/KitManager.kt | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/club/mcscrims/speedhg/game/GameManager.kt b/src/main/kotlin/club/mcscrims/speedhg/game/GameManager.kt index aaf59e2..a5a4a59 100644 --- a/src/main/kotlin/club/mcscrims/speedhg/game/GameManager.kt +++ b/src/main/kotlin/club/mcscrims/speedhg/game/GameManager.kt @@ -263,9 +263,11 @@ class GameManager( plugin.rankingManager.registerRoundKill( killer.uniqueId ) } - player.inventory.contents.filterNotNull().forEach { - player.world.dropItemNaturally( player.location, it ) - } + player.inventory.contents.filterNotNull() + .filter { !plugin.kitManager.isKitItem( player, it ) } + .forEach { item -> + player.world.dropItemNaturally( player.location, item ) + } val msgKey = if ( killer != null ) "game.death-killed" else "game.death-pve" val killerName = killer?.name ?: "Environment" diff --git a/src/main/kotlin/club/mcscrims/speedhg/kit/KitManager.kt b/src/main/kotlin/club/mcscrims/speedhg/kit/KitManager.kt index 69a9649..0e98172 100644 --- a/src/main/kotlin/club/mcscrims/speedhg/kit/KitManager.kt +++ b/src/main/kotlin/club/mcscrims/speedhg/kit/KitManager.kt @@ -3,6 +3,7 @@ package club.mcscrims.speedhg.kit import club.mcscrims.speedhg.SpeedHG import club.mcscrims.speedhg.kit.charge.PlayerChargeData import org.bukkit.entity.Player +import org.bukkit.inventory.ItemStack import java.util.* import java.util.concurrent.ConcurrentHashMap @@ -149,6 +150,18 @@ class KitManager( chargeData.clear() } + /** + * Checks if an item is a kit item from a player + */ + fun isKitItem( + player: Player, + item: ItemStack + ): Boolean + { + val kit = getSelectedKit( player ) ?: return false + return kit.cachedItems[ player.uniqueId ]?.any { it.isSimilar( item ) } == true + } + // ------------------------------------------------------------------------- // Charge access (used by KitEventDispatcher) // -------------------------------------------------------------------------