Table of Contents

Class CustomItem

Namespace
Exiled.CustomItems.API.Features
Assembly
Exiled.CustomItems.dll

The Custom Item base class.

public abstract class CustomItem
Inheritance
CustomItem
Derived
Inherited Members
Extension Methods

Properties

Description

Gets or sets the description of the item.

public abstract string Description { get; set; }

Property Value

string

Id

Gets or sets the custom ItemID of the item.

public abstract uint Id { get; set; }

Property Value

uint

Name

Gets or sets the name of the item.

public abstract string Name { get; set; }

Property Value

string

Registered

Gets the list of current Item Managers.

public static HashSet<CustomItem> Registered { get; }

Property Value

HashSet<CustomItem>

Scale

Gets or sets the scale of the item.

public virtual Vector3 Scale { get; set; }

Property Value

Vector3

ShouldMessageOnGban

Gets a value indicating whether this item causes things to happen that may be considered hacks, and thus be shown to global moderators as being present in a player's inventory when they gban them.

[YamlIgnore]
public virtual bool ShouldMessageOnGban { get; }

Property Value

bool

SpawnProperties

Gets or sets the list of spawn locations and chances for each one.

public abstract SpawnProperties? SpawnProperties { get; set; }

Property Value

SpawnProperties

TrackedSerials

Gets the list of custom items inside players' inventory being tracked as the current item.

[YamlIgnore]
public HashSet<int> TrackedSerials { get; }

Property Value

HashSet<int>

Type

Gets or sets the ItemType to use for this item.

public virtual ItemType Type { get; set; }

Property Value

ItemType

Weight

Gets or sets the weight of the item.

public abstract float Weight { get; set; }

Property Value

float

Methods

Check(Item?)

Checks the specified inventory item to see if it is a custom item.

public virtual bool Check(Item? item)

Parameters

item Item

The Item to check.

Returns

bool

True if it is a custom item.

Check(Pickup?)

Checks the specified pickup to see if it is a custom item.

public virtual bool Check(Pickup? pickup)

Parameters

pickup Pickup

The Pickup to check.

Returns

bool

True if it is a custom item.

Check(Player?)

Checks the specified player's current item to see if it is a custom item.

public virtual bool Check(Player? player)

Parameters

player Player

The Player who's current item should be checked.

Returns

bool

True if it is a custom item.

Destroy()

Called when the item is unregistered.

public virtual void Destroy()

Get(string)

Gets a CustomItem with a specific name.

public static CustomItem? Get(string name)

Parameters

name string

The CustomItem name.

Returns

CustomItem

The CustomItem matching the search, null if not registered.

Get(Type)

Retrieves a collection of CustomItem instances that match a specified type.

public static IEnumerable<CustomItem> Get(Type t)

Parameters

t Type

The Type type.

Returns

IEnumerable<CustomItem>

An IEnumerable<T> containing all registered CustomItem of the specified type.

Get(uint)

Gets a CustomItem with a specific ID.

public static CustomItem? Get(uint id)

Parameters

id uint

The CustomItem ID.

Returns

CustomItem

The CustomItem matching the search, null if not registered.

Give(Player, Item, bool)

Gives an Item as a CustomItem to a Player.

public virtual void Give(Player player, Item item, bool displayMessage = true)

Parameters

player Player

The Player who will receive the item.

item Item

The Item to be given.

displayMessage bool

Indicates whether ShowPickedUpMessage(Player) will be called when the player receives the item.

Give(Player, Pickup, bool)

Gives a InventorySystem.Items.Pickups.ItemPickupBase as a CustomItem to a Player.

public virtual void Give(Player player, Pickup pickup, bool displayMessage = true)

Parameters

player Player

The Player who will receive the item.

pickup Pickup

The InventorySystem.Items.Pickups.ItemPickupBase to be given.

displayMessage bool

Indicates whether ShowPickedUpMessage(Player) will be called when the player receives the item.

Give(Player, bool)

Gives the CustomItem to a player.

public virtual void Give(Player player, bool displayMessage = true)

Parameters

player Player

The Player who will receive the item.

displayMessage bool

Indicates whether ShowPickedUpMessage(Player) will be called when the player receives the item.

Init()

Called when the item is registered.

public virtual void Init()

OnAcquired(Player, Item, bool)

Called anytime the item enters a player's inventory by any means.

protected virtual void OnAcquired(Player player, Item item, bool displayMessage)

Parameters

player Player

The Player acquiring the item.

item Item

The Item being acquired.

displayMessage bool

Whether the Pickup hint should be displayed.

OnChanging(ChangingItemEventArgs)

Handles tracking items when they are selected in the player's inventory.

protected virtual void OnChanging(ChangingItemEventArgs ev)

Parameters

ev ChangingItemEventArgs

ChangingItemEventArgs.

OnDropping(DroppingItemEventArgs)

Handles tracking items when they are dropped by a player.

[Obsolete("Use OnDroppingItem instead.", false)]
protected virtual void OnDropping(DroppingItemEventArgs ev)

Parameters

ev DroppingItemEventArgs

DroppingItemEventArgs.

OnDroppingAmmo(DroppingAmmoEventArgs)

Handles tracking when player requests drop of item which ItemType equals to the ItemType specified by CustomItem.

protected virtual void OnDroppingAmmo(DroppingAmmoEventArgs ev)

Parameters

ev DroppingAmmoEventArgs

DroppingAmmoEventArgs.

OnDroppingItem(DroppingItemEventArgs)

Handles tracking items when they are dropped by a player.

protected virtual void OnDroppingItem(DroppingItemEventArgs ev)

Parameters

ev DroppingItemEventArgs

DroppingItemEventArgs.

OnOwnerChangingRole(OwnerChangingRoleEventArgs)

Handles tracking items when they a player changes their role.

protected virtual void OnOwnerChangingRole(OwnerChangingRoleEventArgs ev)

Parameters

ev OwnerChangingRoleEventArgs

OwnerChangingRoleEventArgs.

OnOwnerDying(OwnerDyingEventArgs)

Handles making sure custom items are not "lost" when a player dies.

protected virtual void OnOwnerDying(OwnerDyingEventArgs ev)

Parameters

ev OwnerDyingEventArgs

OwnerDyingEventArgs.

OnOwnerEscaping(OwnerEscapingEventArgs)

Handles making sure custom items are not "lost" when a player escapes.

protected virtual void OnOwnerEscaping(OwnerEscapingEventArgs ev)

Parameters

ev OwnerEscapingEventArgs

OwnerEscapingEventArgs.

OnOwnerHandcuffing(OwnerHandcuffingEventArgs)

Handles making sure custom items are not "lost" when being handcuffed.

protected virtual void OnOwnerHandcuffing(OwnerHandcuffingEventArgs ev)

Parameters

ev OwnerHandcuffingEventArgs

OwnerHandcuffingEventArgs.

OnPickingUp(PickingUpItemEventArgs)

Handles tracking items when they are picked up by a player.

protected virtual void OnPickingUp(PickingUpItemEventArgs ev)

Parameters

ev PickingUpItemEventArgs

PickingUpItemEventArgs.

OnUpgrading(UpgradingEventArgs)

Handles making sure custom items are not affected by SCP-914.

protected virtual void OnUpgrading(UpgradingEventArgs ev)

Parameters

ev UpgradingEventArgs

UpgradingEventArgs.

OnUpgrading(UpgradingItemEventArgs)

Handles making sure custom items are not affected by SCP-914.

protected virtual void OnUpgrading(UpgradingItemEventArgs ev)

Parameters

ev UpgradingItemEventArgs

UpgradingEventArgs.

OnWaitingForPlayers()

Clears the lists of item uniqIDs and Pickups since any still in the list will be invalid.

protected virtual void OnWaitingForPlayers()

RegisterItems(bool, object?)

Registers all the CustomItem's present in the current assembly.

public static IEnumerable<CustomItem> RegisterItems(bool skipReflection = false, object? overrideClass = null)

Parameters

skipReflection bool

Whether reflection is skipped (more efficient if you are not using your custom item classes as config objects).

overrideClass object

The class to search properties for, if different from the plugin's config class.

Returns

IEnumerable<CustomItem>

A IEnumerable<T> of CustomItem which contains all registered CustomItem's.

RegisterItems(IEnumerable<Type>, bool, bool, object?)

Registers all the CustomItem's present in the current assembly.

public static IEnumerable<CustomItem> RegisterItems(IEnumerable<Type> targetTypes, bool isIgnored = false, bool skipReflection = false, object? overrideClass = null)

Parameters

targetTypes IEnumerable<Type>

The IEnumerable<T> of Type containing the target types.

isIgnored bool

A value indicating whether the target types should be ignored.

skipReflection bool

Whether reflection is skipped (more efficient if you are not using your custom item classes as config objects).

overrideClass object

The class to search properties for, if different from the plugin's config class.

Returns

IEnumerable<CustomItem>

A IEnumerable<T> of CustomItem which contains all registered CustomItem's.

ShowPickedUpMessage(Player)

Shows a message to the player upon picking up a custom item.

protected virtual void ShowPickedUpMessage(Player player)

Parameters

player Player

The Player who will be shown the message.

ShowSelectedMessage(Player)

Shows a message to the player upon selecting a custom item.

protected virtual void ShowSelectedMessage(Player player)

Parameters

player Player

The Player who will be shown the message.

Spawn(Player, Item, Player?)

Spawns a Item as a CustomItem where a specific Player is, and optionally sets the previous owner.

public virtual Pickup? Spawn(Player player, Item item, Player? previousOwner = null)

Parameters

player Player

The Player position where the CustomItem will be spawned.

item Item

The Item to be spawned as a CustomItem.

previousOwner Player

The previous owner of the pickup, can be null.

Returns

Pickup

The Pickup of the spawned CustomItem.

Spawn(Player, Player?)

Spawns the CustomItem where a specific Player is, and optionally sets the previous owner.

public virtual Pickup? Spawn(Player player, Player? previousOwner = null)

Parameters

player Player

The Player position where the CustomItem will be spawned.

previousOwner Player

The previous owner of the pickup, can be null.

Returns

Pickup

The Pickup of the spawned CustomItem.

Spawn(IEnumerable<SpawnPoint>, uint)

Spawns CustomItems inside spawnPoints.

public virtual uint Spawn(IEnumerable<SpawnPoint> spawnPoints, uint limit)

Parameters

spawnPoints IEnumerable<SpawnPoint>

The spawn points IEnumerable<T>.

limit uint

The spawn limit.

Returns

uint

Returns the number of spawned items.

Spawn(float, float, float)

Spawns the CustomItem in a specific location.

public virtual Pickup? Spawn(float x, float y, float z)

Parameters

x float

The x coordinate.

y float

The y coordinate.

z float

The z coordinate.

Returns

Pickup

The Pickup wrapper of the spawned CustomItem.

Spawn(float, float, float, Item)

Spawns a Item as a CustomItem in a specific location.

public virtual Pickup? Spawn(float x, float y, float z, Item item)

Parameters

x float

The x coordinate.

y float

The y coordinate.

z float

The z coordinate.

item Item

The Item to be spawned as a CustomItem.

Returns

Pickup

The Pickup wrapper of the spawned CustomItem.

Spawn(Vector3, Item, Player?)

Spawns the CustomItem in a specific position.

public virtual Pickup? Spawn(Vector3 position, Item item, Player? previousOwner = null)

Parameters

position Vector3

The UnityEngine.Vector3 where the CustomItem will be spawned.

item Item

The Item to be spawned as a CustomItem.

previousOwner Player

The PreviousOwner of the item. Can be null.

Returns

Pickup

The Pickup of the spawned CustomItem.

Spawn(Vector3, Player?)

Spawns the CustomItem in a specific position.

public virtual Pickup? Spawn(Vector3 position, Player? previousOwner = null)

Parameters

position Vector3

The UnityEngine.Vector3 where the CustomItem will be spawned.

previousOwner Player

The PreviousOwner of the item. Can be null.

Returns

Pickup

The Pickup of the spawned CustomItem.

SpawnAll()

Spawns all items at their dynamic and static positions.

public virtual void SpawnAll()

SubscribeEvents()

Called after the manager is initialized, to allow loading of special event handlers.

protected virtual void SubscribeEvents()

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGet(Item, out CustomItem?)

Checks to see if this item is a custom item.

public static bool TryGet(Item item, out CustomItem? customItem)

Parameters

item Item

The Item to check.

customItem CustomItem

The CustomItem this item is.

Returns

bool

True if the item is a custom item.

TryGet(Pickup, out CustomItem?)

Checks if this pickup is a custom item.

public static bool TryGet(Pickup pickup, out CustomItem? customItem)

Parameters

pickup Pickup

The InventorySystem.Items.Pickups.ItemPickupBase to check.

customItem CustomItem

The CustomItem this pickup is.

Returns

bool

True if the pickup is a custom item.

TryGet(Player, out CustomItem?)

Tries to get the player's current CustomItem in their hand.

public static bool TryGet(Player player, out CustomItem? customItem)

Parameters

player Player

The Player to check.

customItem CustomItem

The CustomItem in their hand.

Returns

bool

Returns a value indicating whether the Player has a CustomItem in their hand or not.

TryGet(Player, out IEnumerable<CustomItem>?)

Tries to get the player's IEnumerable<T> of CustomItem.

public static bool TryGet(Player player, out IEnumerable<CustomItem>? customItems)

Parameters

player Player

The Player to check.

customItems IEnumerable<CustomItem>

The player's IEnumerable<T> of CustomItem.

Returns

bool

Returns a value indicating whether the Player has a CustomItem in their hand or not.

TryGet(string, out CustomItem?)

Tries to get a CustomItem with a specific name.

public static bool TryGet(string name, out CustomItem? customItem)

Parameters

name string

The CustomItem name to look for.

customItem CustomItem

The found CustomItem, null if not registered.

Returns

bool

Returns a value indicating whether the CustomItem was found.

TryGet(Type, out IEnumerable<CustomItem>)

Attempts to retrieve a collection of CustomItem instances of a specified type.

public static bool TryGet(Type t, out IEnumerable<CustomItem> customItems)

Parameters

t Type

The Type of the item to look for.

customItems IEnumerable<CustomItem>

An output parameter that will contain the found CustomItem instances, or an empty collection if none are registered.

Returns

bool

A boolean value indicating whether any CustomItem instances of the specified type were found.

TryGet(uint, out CustomItem?)

Tries to get a CustomItem with a specific ID.

public static bool TryGet(uint id, out CustomItem? customItem)

Parameters

id uint

The CustomItem ID to look for.

customItem CustomItem

The found CustomItem, null if not registered.

Returns

bool

Returns a value indicating whether the CustomItem was found.

TryGive(Player, string, bool)

Gives to a specific Player a specic CustomItem.

public static bool TryGive(Player player, string name, bool displayMessage = true)

Parameters

player Player

The Player to give the item to.

name string

The name of the CustomItem to give.

displayMessage bool

Indicates a value whether ShowPickedUpMessage(Player) will be called when the player receives the CustomItem or not.

Returns

bool

Returns a value indicating if the player was given the CustomItem or not.

TryGive(Player, uint, bool)

Gives to a specific Player a specic CustomItem.

public static bool TryGive(Player player, uint id, bool displayMessage = true)

Parameters

player Player

The Player to give the item to.

id uint

The IDs of the CustomItem to give.

displayMessage bool

Indicates a value whether ShowPickedUpMessage(Player) will be called when the player receives the CustomItem or not.

Returns

bool

Returns a value indicating if the player was given the CustomItem or not.

TrySpawn(string, Vector3, out Pickup?)

Tries to spawn a specific CustomItem at a specific UnityEngine.Vector3 position.

public static bool TrySpawn(string name, Vector3 position, out Pickup? pickup)

Parameters

name string

The name of the CustomItem to spawn.

position Vector3

The UnityEngine.Vector3 location to spawn the item.

pickup Pickup

The InventorySystem.Items.Pickups.ItemPickupBase instance of the CustomItem.

Returns

bool

Returns a value indicating whether the CustomItem was spawned.

TrySpawn(uint, Vector3, out Pickup?)

Tries to spawn a specific CustomItem at a specific UnityEngine.Vector3 position.

public static bool TrySpawn(uint id, Vector3 position, out Pickup? pickup)

Parameters

id uint

The ID of the CustomItem to spawn.

position Vector3

The UnityEngine.Vector3 location to spawn the item.

pickup Pickup

The InventorySystem.Items.Pickups.ItemPickupBase instance of the CustomItem.

Returns

bool

Returns a value indicating whether the CustomItem was spawned.

UnregisterItems()

Unregisters all the CustomItem's present in the current assembly.

public static IEnumerable<CustomItem> UnregisterItems()

Returns

IEnumerable<CustomItem>

A IEnumerable<T> of CustomItem which contains all unregistered CustomItem's.

UnregisterItems(IEnumerable<CustomItem>, bool)

Unregisters all the CustomItem's present in the current assembly.

public static IEnumerable<CustomItem> UnregisterItems(IEnumerable<CustomItem> targetItems, bool isIgnored = false)

Parameters

targetItems IEnumerable<CustomItem>

The IEnumerable<T> of CustomItem containing the target items.

isIgnored bool

A value indicating whether the target items should be ignored.

Returns

IEnumerable<CustomItem>

A IEnumerable<T> of CustomItem which contains all unregistered CustomItem's.

UnregisterItems(IEnumerable<Type>, bool)

Unregisters all the CustomItem's present in the current assembly.

public static IEnumerable<CustomItem> UnregisterItems(IEnumerable<Type> targetTypes, bool isIgnored = false)

Parameters

targetTypes IEnumerable<Type>

The IEnumerable<T> of Type containing the target types.

isIgnored bool

A value indicating whether the target types should be ignored.

Returns

IEnumerable<CustomItem>

A IEnumerable<T> of CustomItem which contains all unregistered CustomItem's.

UnsubscribeEvents()

Called when the manager is being destroyed, to allow unloading of special event handlers.

protected virtual void UnsubscribeEvents()