Skip to content

Commit

Permalink
fix nullref pt.2
Browse files Browse the repository at this point in the history
  • Loading branch information
moddedmcplayer committed Jun 19, 2022
1 parent 3843a6a commit f12201c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hats/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class EventHandler

public void WaitingForPlayers()
{
if (API.Hats.Count != 0)
return;
API.LoadHats();
}

Expand All @@ -20,5 +22,10 @@ public void OnLeave(LeftEventArgs ev)
if(ev.Player.GameObject.TryGetComponent<HatComponent>(out _))
ev.Player.RemoveHat();
}

public void EndingRound(EndingRoundEventArgs ev)
{
API.LoadHats();
}
}
}
2 changes: 2 additions & 0 deletions hats/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit f12201c

Please sign in to comment.