From 58ae81e811bf6447bd9bee948effaf436a5a8577 Mon Sep 17 00:00:00 2001 From: Hamunii <samuel.suni04@gmail.com> Date: Sat, 24 Aug 2024 09:20:40 +0300 Subject: [PATCH] fix: validating content adds it to Mod.Content list --- src/ContentLib.Core/ContentDefinition.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ContentLib.Core/ContentDefinition.cs b/src/ContentLib.Core/ContentDefinition.cs index fd5582c..4d14f35 100644 --- a/src/ContentLib.Core/ContentDefinition.cs +++ b/src/ContentLib.Core/ContentDefinition.cs @@ -47,18 +47,20 @@ public virtual (bool isValid, string? message) Validate() $"The `{nameof(ModDefinition)} {nameof(Mod)}` of this ContentDefinition exists but isn't registered! " + "Please create your ModDefinition through intended methods."); } - - return result; } - - if (!TryGetModDefinitionFromCallingAssembly(out ModDefinition? modDefinition)) + else if (TryGetModDefinitionFromCallingAssembly(out ModDefinition? modDefinition)) + Mod = modDefinition; + else { MarkAsInvalid(ref result, $"Tried getting {nameof(BepInPlugin)} Attribute from CallingAssembly, but the attribute was not found! " + "Make sure to call ContentLib from a valid BepInEx Plugin assembly."); + + return result; } - Mod = modDefinition; + if (!Mod.Content.Contains(this)) + Mod.Content.Add(this); return result; }