Merge pull request #267 from Intovoice/fire-user-events

Fire user events
This commit is contained in:
Deantwo 2022-07-19 17:14:49 +02:00 committed by GitHub
commit c4df9d8ecb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -719,9 +719,10 @@ namespace AsterNET.Manager
private void internalEventHandler(object sender, ManagerEvent e) private void internalEventHandler(object sender, ManagerEvent e)
{ {
int eventHash = e.GetType().Name.GetHashCode(); int eventHash = e.GetType().Name.GetHashCode();
if (registeredEventHandlers.ContainsKey(eventHash)) int userEventHash = typeof(UserEvent).Name.GetHashCode();
if (registeredEventHandlers.TryGetValue(eventHash, out var currentEvent)
|| (registeredEventHandlers.TryGetValue(userEventHash, out currentEvent) && typeof(UserEvent).IsAssignableFrom(e.GetType())))
{ {
var currentEvent = registeredEventHandlers[eventHash];
if (currentEvent(e)) if (currentEvent(e))
{ {
return; return;