diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index aa096dc85d..1ad086c77c 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -53,7 +53,6 @@ namespace Exiled.CustomItems.API.Features /// public abstract class CustomItem { - private static Dictionary typeLookupTable = new(); private static Dictionary stringLookupTable = new(); private static Dictionary idLookupTable = new(); @@ -159,16 +158,11 @@ public virtual ItemType Type } /// - /// Gets a with a specific type. + /// Retrieves a collection of instances that match a specified type. /// /// The type. - /// The matching the search, if not registered. - public static CustomItem? Get(Type t) - { - if (!typeLookupTable.ContainsKey(t)) - typeLookupTable.Add(t, Registered.FirstOrDefault(i => i.GetType() == t)); - return typeLookupTable[t]; - } + /// An containing all registered of the specified type. + public static IEnumerable Get(Type t) => Registered.Where(i => i.GetType() == t); /// /// Tries to get a with a specific ID. @@ -201,16 +195,16 @@ public static bool TryGet(string name, out CustomItem? customItem) } /// - /// Tries to get a with a specific type. + /// Attempts to retrieve a collection of instances of a specified type. /// /// The of the item to look for. - /// The found , if not registered. - /// Returns a value indicating whether the was found. - public static bool TryGet(Type t, out CustomItem? customItem) + /// An output parameter that will contain the found instances, or an empty collection if none are registered. + /// A boolean value indicating whether any instances of the specified type were found. + public static bool TryGet(Type t, out IEnumerable customItems) { - customItem = Get(t); + customItems = Get(t); - return customItem is not null; + return customItems.Any(); } /// @@ -345,23 +339,6 @@ public static bool TryGive(Player player, uint id, bool displayMessage = true) return true; } - /// - /// Gives to a specific a specic . - /// - /// The to give the item to. - /// The of the item to give. - /// Indicates a value whether will be called when the player receives the or not. - /// Returns a value indicating if the player was given the or not. - public static bool TryGive(Player player, Type t, bool displayMessage = true) - { - if (!TryGet(t, out CustomItem? item)) - return false; - - item?.Give(player, displayMessage); - - return true; - } - /// /// Registers all the 's present in the current assembly. /// @@ -770,7 +747,6 @@ public virtual void Give(Player player, Item item, bool displayMessage = true) /// public virtual void Init() { - typeLookupTable.Add(GetType(), this); stringLookupTable.Add(Name, this); idLookupTable.Add(Id, this); @@ -784,7 +760,6 @@ public virtual void Destroy() { UnsubscribeEvents(); - typeLookupTable.Remove(GetType()); stringLookupTable.Remove(Name); idLookupTable.Remove(Id); }