fix: Fixes null components in BaseAddon (#2208)

This commit is contained in:
Kamron Batman 2025-06-02 22:11:40 -10:00 committed by GitHub
parent 78e2e24fcd
commit 0d2ed60fed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -104,7 +104,7 @@ namespace Server.Items
}
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializedCommandProperty(AccessLevel.GameMaster, readOnly: true)]
public BaseAddon _addon;
[SerializableField(1)]

View file

@ -270,7 +270,8 @@ namespace Server.Items
foreach (var c in Components)
{
c.Delete();
// Component can become null if the Addon property is somehow deleted, then the component itself is deleted.
c?.Delete();
}
}
@ -283,5 +284,12 @@ namespace Server.Items
_resource = (CraftResource)reader.ReadEncodedInt();
}
}
[AfterDeserialization]
private void AfterDeserialization()
{
// We have had issues in the past, so let's tidy it up.
_components?.Tidy();
}
}
}