Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,36 @@ public void DropItem(Item item, bool isThrown = false)
/// <returns>dropped <see cref="Pickup"/>.</returns>
public Pickup DropItem(Item item) => item is not null ? Pickup.Get(Inventory.ServerDropItem(item.Serial)) : null;

/// <summary>
/// Drops an <see cref="Item"/> from the player's inventory by its <see cref="ItemType"/>.
/// </summary>
/// <param name="item">The specified <see cref="ItemType"/> to be dropped.</param>
/// <param name="isThrown">Is the item Thrown?.</param>
/// <returns>A value indicating whether the <see cref="Item"/> was dropped.</returns>
public bool DropItem(ItemType item, bool isThrown = false)
{
Item itemtodrop = Items.FirstOrDefault(tempItem => tempItem.Type == item);
if (itemtodrop == null)
return false;

DropItem(itemtodrop, isThrown);
return true;
}

/// <summary>
/// Drops an item from the player's inventory.
/// </summary>
/// <param name="item">The specified <see cref="ItemType"/> to be dropped.</param>
/// <returns>dropped <see cref="Pickup"/>.</returns>
public Pickup DropItem(ItemType item)
{
Item itemtodrop = Items.FirstOrDefault(tempItem => tempItem.Type == item);
if (itemtodrop == null)
return null;

return Pickup.Get(Inventory.ServerDropItem(itemtodrop.Serial));
}

/// <summary>
/// Drops the held item. Will not do anything if the player is not holding an item.
/// </summary>
Expand Down Expand Up @@ -2138,6 +2168,22 @@ public bool RemoveItem(Item item, bool destroy = true)
return true;
}

/// <summary>
/// Removes an <see cref="Item"/> from the player's inventory by its <see cref="ItemType"/>.
/// </summary>
/// <param name="item">The specified <see cref="ItemType"/> to be removed.</param>
/// <param name="destroy">Whether to destroy the item.</param>
/// <returns>A value indicating whether the <see cref="Item"/> was removed.</returns>
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;
}

/// <summary>
/// Removes an <see cref="Item"/> from the player's inventory.
/// </summary>
Expand Down
Loading