From f12201c0e4c0923266813d4bfa040923607c171d Mon Sep 17 00:00:00 2001 From: moddedmcplayer Date: Sun, 19 Jun 2022 19:52:08 +0200 Subject: [PATCH] fix nullref pt.2 --- hats/EventHandler.cs | 7 +++++++ hats/Plugin.cs | 2 ++ 2 files changed, 9 insertions(+) diff --git a/hats/EventHandler.cs b/hats/EventHandler.cs index ffcca35..f56e4cd 100644 --- a/hats/EventHandler.cs +++ b/hats/EventHandler.cs @@ -12,6 +12,8 @@ public class EventHandler public void WaitingForPlayers() { + if (API.Hats.Count != 0) + return; API.LoadHats(); } @@ -20,5 +22,10 @@ public void OnLeave(LeftEventArgs ev) if(ev.Player.GameObject.TryGetComponent(out _)) ev.Player.RemoveHat(); } + + public void EndingRound(EndingRoundEventArgs ev) + { + API.LoadHats(); + } } } \ No newline at end of file diff --git a/hats/Plugin.cs b/hats/Plugin.cs index 0d19b54..d6bd90c 100644 --- a/hats/Plugin.cs +++ b/hats/Plugin.cs @@ -26,6 +26,7 @@ public override void OnEnabled() Handler = new EventHandler(Config); Server.WaitingForPlayers += Handler.WaitingForPlayers; + Server.EndingRound += Handler.EndingRound; Player.Left += Handler.OnLeave; base.OnEnabled(); @@ -34,6 +35,7 @@ public override void OnEnabled() public override void OnDisabled() { Server.WaitingForPlayers -= Handler.WaitingForPlayers; + Server.EndingRound -= Handler.EndingRound; Player.Left -= Handler.OnLeave; Singleton = null;