diff --git a/MiraAPI/Events/MiraEventManager.cs b/MiraAPI/Events/MiraEventManager.cs index adfb2627..4d733940 100644 --- a/MiraAPI/Events/MiraEventManager.cs +++ b/MiraAPI/Events/MiraEventManager.cs @@ -138,12 +138,12 @@ public static class MiraEventManager /// /// Register a handler. /// + /// The type of event. /// The of the event handler. /// The priority of the event handler. Lower values are called first. /// A to use when unregistering the event. - public static MiraEventHandle RegisterEventHandler(MethodInfo methodInfo, int priority = 0) + public static MiraEventHandle RegisterEventHandler(Type type, MethodInfo methodInfo, int priority = 0) { - Type type = methodInfo.GetParameters()[0].ParameterType; if (!type.IsAssignableTo(typeof(MiraEvent))) { throw new InvalidOperationException($"Type must be a subclass of MiraEvent: {type.FullName}"); diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 83a784e6..b4815048 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -197,7 +197,8 @@ public sealed class MiraPluginManager continue; } - MiraEventManager.RegisterEventHandler(method, eventAttribute.Priority); + var paramType = parameters[0].ParameterType; + MiraEventManager.RegisterEventHandler(paramType, method, eventAttribute.Priority); } }