|
@@ -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);
|
|
}
|
|
}
|
|
|
|
|