diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index a377c0a483..029db5203d 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -2048,6 +2048,49 @@ public void DropItem(Item item, bool isThrown = false) /// dropped . public Pickup DropItem(Item item) => item is not null ? Pickup.Get(Inventory.ServerDropItem(item.Serial)) : null; + /// + /// Drops an from the player's inventory by its . + /// + /// The specified to be dropped. + /// Whether the item should be thrown. + /// The number of matching items to remove. + /// A value indicating whether the was dropped. + public bool DropItem(ItemType item, bool isThrown = false, int amount = 1) + { + if (amount <= 0) + return false; + + List itemsToDrop = Items.Where(i => i?.Type == item).Take(amount).ToList(); + + if (itemsToDrop.Count == 0) + return false; + + foreach (Item i in itemsToDrop) + DropItem(i, isThrown); + + return itemsToDrop.Count > 0; + } + + /// + /// Drops an item from the player's inventory. + /// + /// The specified to be dropped. + /// The number of matching items to remove. + /// A list of dropped s. + public List DropItem(ItemType item, int amount = 1) + { + List pickups = new(); + + if (amount <= 0) + return pickups; + + List itemsToDrop = Items.Where(i => i?.Type == item).Take(amount).ToList(); + + foreach (Item i in itemsToDrop) + pickups.Add(DropItem(i)); + + return pickups; + } /// /// Drops the held item. Will not do anything if the player is not holding an item. /// @@ -2155,6 +2198,22 @@ public bool RemoveItem(Item item, bool destroy = true) return true; } + /// + /// Removes an from the player's inventory by its . + /// + /// The specified to be removed. + /// Whether to destroy the item. + /// A value indicating whether the was removed. + public bool RemoveItem(ItemType item, bool destroy = true) + { + Item itemtoremove = Items.FirstOrDefault(tempItem => tempItem.Type == item); + if (itemtoremove == null) + return false; + + RemoveItem(itemtoremove, destroy); + return true; + } + /// /// Removes an from the player's inventory. ///