diff --git a/MiraAPI/Events/MiraEventManager.cs b/MiraAPI/Events/MiraEventManager.cs
index e5d296e1..b5bbfad9 100644
--- a/MiraAPI/Events/MiraEventManager.cs
+++ b/MiraAPI/Events/MiraEventManager.cs
@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using MiraAPI.PluginLoading;
+using MiraAPI.Utilities;
namespace MiraAPI.Events;
@@ -113,28 +114,6 @@ public static class MiraEventManager
trackedEvents.Add(trackedAs);
}
- private static bool IsSubclassOfWithGeneric(this Type? type, Type super)
- {
- if (type == null || type == typeof(MiraEvent))
- {
- return false;
- }
-
- if (type == super)
- {
- return true;
- }
-
- if (super.IsGenericTypeDefinition &&
- type.IsGenericType &&
- type.GetGenericTypeDefinition() == super)
- {
- return true;
- }
-
- return type.BaseType.IsSubclassOfWithGeneric(super);
- }
-
///
/// Register a handler.
///
diff --git a/MiraAPI/Utilities/Extensions.cs b/MiraAPI/Utilities/Extensions.cs
index d3a0fbae..29f8b623 100644
--- a/MiraAPI/Utilities/Extensions.cs
+++ b/MiraAPI/Utilities/Extensions.cs
@@ -601,6 +601,35 @@ public static class Extensions
return type is { IsClass: true, IsAbstract: true, IsSealed: true };
}
+ ///
+ /// Checks if is a subclass of , including
+ /// account for generics, or given generic type definitions.
+ ///
+ /// The type to check.
+ /// The type to compare against.
+ /// if is a sublass of , otherwise.
+ public static bool IsSubclassOfWithGeneric(this Type? type, Type super)
+ {
+ if (type == null || type == typeof(object))
+ {
+ return false;
+ }
+
+ if (type == super)
+ {
+ return true;
+ }
+
+ if (super.IsGenericTypeDefinition &&
+ type.IsGenericType &&
+ type.GetGenericTypeDefinition() == super)
+ {
+ return true;
+ }
+
+ return type.BaseType.IsSubclassOfWithGeneric(super);
+ }
+
///
/// Gets a darkened version of a .
///