Browse Source

Fixed newly added settings not getting written until they are changed

ManlyMarco 5 years ago
parent
commit
095bdbece1
1 changed files with 6 additions and 0 deletions
  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)))
 			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())}");
 				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);
 			Entries.TryGetValue(configDefinition, out var entry);
 
 
 			if (entry == null)
 			if (entry == null)
 			{
 			{
 				entry = new ConfigEntry(this, configDefinition, typeof(T), defaultValue);
 				entry = new ConfigEntry(this, configDefinition, typeof(T), defaultValue);
 				Entries[configDefinition] = entry;
 				Entries[configDefinition] = entry;
+				forceSave = true;
 			}
 			}
 			else
 			else
 			{
 			{
@@ -210,6 +213,9 @@ namespace BepInEx.Configuration
 				entry.SetDescription(configDescription);
 				entry.SetDescription(configDescription);
 			}
 			}
 
 
+			if(forceSave)
+				Save();
+
 			return new ConfigWrapper<T>(entry);
 			return new ConfigWrapper<T>(entry);
 		}
 		}