diff --git a/Exiled.API/Features/Core/Generic/EnumClass.cs b/Exiled.API/Features/Core/Generic/EnumClass.cs index cf9413f66a..de21ddfaac 100644 --- a/Exiled.API/Features/Core/Generic/EnumClass.cs +++ b/Exiled.API/Features/Core/Generic/EnumClass.cs @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic using System.Reflection; using Exiled.API.Features.Core.Generic.Pools; - + using Exiled.API.Interfaces; using LiteNetLib.Utils; /// @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic /// /// The type of the source object to handle the instance of. /// The type of the child object to handle the instance of. - public abstract class EnumClass : IComparable, IEquatable, IComparable, IComparer + public abstract class EnumClass : IComparable, IEquatable, IComparable, IComparer, IEnumClass where TSource : Enum where TObject : EnumClass { diff --git a/Exiled.API/Features/Core/Generic/UniqueUnmanagedEnumClass.cs b/Exiled.API/Features/Core/Generic/UniqueUnmanagedEnumClass.cs index 94a91cac48..f71d7366f6 100644 --- a/Exiled.API/Features/Core/Generic/UniqueUnmanagedEnumClass.cs +++ b/Exiled.API/Features/Core/Generic/UniqueUnmanagedEnumClass.cs @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic using System.Reflection; using Exiled.API.Features.Core.Generic.Pools; - + using Exiled.API.Interfaces; using LiteNetLib.Utils; /// @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic /// /// The type of the source object to handle the instance of. /// The type of the child object to handle the instance of. - public abstract class UniqueUnmanagedEnumClass : IComparable, IEquatable, IComparable, IComparer, IConvertible + public abstract class UniqueUnmanagedEnumClass : IComparable, IEquatable, IComparable, IComparer, IConvertible, IEnumClass where TSource : unmanaged, IComparable, IFormattable, IConvertible, IComparable, IEquatable where TObject : UniqueUnmanagedEnumClass { diff --git a/Exiled.API/Features/Core/Generic/UnmanagedEnumClass.cs b/Exiled.API/Features/Core/Generic/UnmanagedEnumClass.cs index 63308fa4e1..a4697db89c 100644 --- a/Exiled.API/Features/Core/Generic/UnmanagedEnumClass.cs +++ b/Exiled.API/Features/Core/Generic/UnmanagedEnumClass.cs @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic using System.Reflection; using Exiled.API.Features.Core.Generic.Pools; - + using Exiled.API.Interfaces; using LiteNetLib.Utils; /// @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic /// /// The type of the source object to handle the instance of. /// The type of the child object to handle the instance of. - public abstract class UnmanagedEnumClass : IComparable, IEquatable, IComparable, IComparer, IConvertible + public abstract class UnmanagedEnumClass : IComparable, IEquatable, IComparable, IComparer, IConvertible, IEnumClass where TSource : unmanaged, IComparable, IFormattable, IConvertible, IComparable, IEquatable where TObject : UnmanagedEnumClass { diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 7d35f9ec56..7ab83c5bae 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -112,11 +112,6 @@ internal Pickup(ItemType type) /// A randomly selected object. public static Pickup Random => BaseToPickup.Random().Value; - /// - /// Gets the of the Pickup. - /// - public override GameObject GameObject => GameObject; - /// /// Gets the of the Pickup. /// diff --git a/Exiled.API/Interfaces/IEnumClass.cs b/Exiled.API/Interfaces/IEnumClass.cs new file mode 100644 index 0000000000..5d83750967 --- /dev/null +++ b/Exiled.API/Interfaces/IEnumClass.cs @@ -0,0 +1,16 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Interfaces +{ + /// + /// An interface for all enum classes. + /// + public interface IEnumClass + { + } +} \ No newline at end of file diff --git a/Exiled.Events/Events.cs b/Exiled.Events/Events.cs index 4520134870..b0c7f5386f 100644 --- a/Exiled.Events/Events.cs +++ b/Exiled.Events/Events.cs @@ -9,10 +9,13 @@ namespace Exiled.Events { using System; using System.Diagnostics; + using System.Linq; + using System.Reflection; using API.Enums; using API.Features; using CentralAuth; + using Exiled.API.Interfaces; using Exiled.Events.Features; using HarmonyLib; using InventorySystem.Items.Pickups; @@ -83,6 +86,19 @@ public override void OnEnabled() ServerConsole.ReloadServerName(); EventManager.RegisterEvents(this); + + foreach (Type type in typeof(IEnumClass).Assembly.GetTypes().Where(x => x.GetInterface(nameof(IEnumClass)) == typeof(IEnumClass))) + { + FieldInfo[] fieldInfos = type.GetFields(); + + if (fieldInfos.All(x => !x.IsInitOnly)) + continue; + + foreach (FieldInfo field in fieldInfos.Where(x => x.IsStatic)) + { + field.GetValue(null); + } + } } ///