Переглянути джерело

Fixed newly added settings not getting written until they are changed

ManlyMarco 5 роки тому
батько
коміт
095bdbece1
1 змінених файлів з 6 додано та 0 видалено
  1. 6 0
      BepInEx/Configuration/ConfigFile.cs

+ 6 - 0
BepInEx/Configuration/ConfigFile.cs

@@ -183,12 +183,15 @@ namespace BepInEx.Configuration
 			if (!TomlTypeConverter.CanConvert(typeof(T)))
 				throw new ArgumentException($"Type {typeof(T)} is not supported by the config system. Supported types: {string.Join(", ", TomlTypeConverter.GetSupportedTypes().Select(x => x.Name).ToArray())}");
 
+			var forceSave = false;
+
 			Entries.TryGetValue(configDefinition, out var entry);
 
 			if (entry == null)
 			{
 				entry = new ConfigEntry(this, configDefinition, typeof(T), defaultValue);
 				Entries[configDefinition] = entry;
+				forceSave = true;
 			}
 			else
 			{
@@ -210,6 +213,9 @@ namespace BepInEx.Configuration
 				entry.SetDescription(configDescription);
 			}
 
+			if(forceSave)
+				Save();
+
 			return new ConfigWrapper<T>(entry);
 		}