diff --git a/api/AltV.Net.Shared/Events/HashSetEventHandler.cs b/api/AltV.Net.Shared/Events/HashSetEventHandler.cs index 27f7701eb..a2254fada 100644 --- a/api/AltV.Net.Shared/Events/HashSetEventHandler.cs +++ b/api/AltV.Net.Shared/Events/HashSetEventHandler.cs @@ -18,15 +18,19 @@ public HashSetEventHandler() public void Add(TEvent value) { if (value == null) return; - if (type != null) core.EventStateManager.AddHandler(type.Value); - events.Add(value); + if (events.Add(value)) + { + if (type != null) core.EventStateManager.AddHandler(type.Value); + } } public void Remove(TEvent value) { if (value == null) return; - if (type != null) core.EventStateManager.RemoveHandler(type.Value); - events.Remove(value); + if (events.Remove(value)) + { + if (type != null) core.EventStateManager.RemoveHandler(type.Value); + } } public HashSet GetEvents() => events;