Update config field check to correctly check TSettings fields
This commit is contained in:
parent
51f179f84a
commit
7bbc647b2f
1 changed files with 5 additions and 2 deletions
|
|
@ -210,14 +210,17 @@ namespace TShockAPI
|
|||
internal static TSettings LoadConfigAndCheckForMissingFields<TSettings>(JObject jObject, out bool anyMissingFields) where TSettings : new()
|
||||
{
|
||||
anyMissingFields = false;
|
||||
var configFields = new HashSet<string>(typeof(Configuration.ConfigFile<TSettings>).GetFields()
|
||||
|
||||
var configFields = new HashSet<string>(typeof(TSettings).GetFields()
|
||||
.Where(field => !field.IsStatic)
|
||||
.Select(field => field.Name));
|
||||
var jsonFields = new HashSet<string>(jObject
|
||||
|
||||
var jsonFields = new HashSet<string>(jObject.SelectToken("Settings")
|
||||
.Children()
|
||||
.Select(field => field as JProperty)
|
||||
.Where(field => field != null)
|
||||
.Select(field => field.Name));
|
||||
|
||||
anyMissingFields = !configFields.SetEquals(jsonFields);
|
||||
|
||||
return jObject.SelectToken("Settings").ToObject<TSettings>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue