From 3843a6ac5fa8761d09cd2345c928726ec6e45b63 Mon Sep 17 00:00:00 2001 From: moddedmcplayer Date: Sat, 18 Jun 2022 12:18:06 +0200 Subject: [PATCH] fix error --- hats/Hat.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hats/Hat.cs b/hats/Hat.cs index 483ef8a..d3438d1 100644 --- a/hats/Hat.cs +++ b/hats/Hat.cs @@ -30,6 +30,11 @@ public void DestroyInstances() List> toRemove = new List>(); foreach (var kvp in Plugin.Singleton.hats.Where(x => x.Value.hat == this)) { + if (kvp.Value is null || kvp.Value.gameObject.Equals(null) || !kvp.Value.schem.isActiveAndEnabled) + { + toRemove.Add(kvp); + continue; + } kvp.Value.DoDestroy(); toRemove.Add(kvp); }