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:
@@ -263,8 +263,10 @@ 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"
|
||||
|
||||
@@ -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)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user