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.
This commit is contained in:
TDSTOS
2026-04-12 05:45:04 +02:00
parent a60241358b
commit 140ee8ef3e
2 changed files with 18 additions and 3 deletions

View File

@@ -263,8 +263,10 @@ class GameManager(
plugin.rankingManager.registerRoundKill( killer.uniqueId ) plugin.rankingManager.registerRoundKill( killer.uniqueId )
} }
player.inventory.contents.filterNotNull().forEach { player.inventory.contents.filterNotNull()
player.world.dropItemNaturally( player.location, it ) .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 msgKey = if ( killer != null ) "game.death-killed" else "game.death-pve"

View File

@@ -3,6 +3,7 @@ package club.mcscrims.speedhg.kit
import club.mcscrims.speedhg.SpeedHG import club.mcscrims.speedhg.SpeedHG
import club.mcscrims.speedhg.kit.charge.PlayerChargeData import club.mcscrims.speedhg.kit.charge.PlayerChargeData
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.util.* import java.util.*
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
@@ -149,6 +150,18 @@ class KitManager(
chargeData.clear() 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) // Charge access (used by KitEventDispatcher)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------