public static void Load() { Engine.PlayerInitializedEvent += PlayerInitialized; string configPath = Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "Assistant.json"); if (!File.Exists(configPath)) { LastProfile = Options.DEFAULT_SETTINGS_FILENAME; UserId = Guid.NewGuid().ToString(); SessionId = Guid.NewGuid().ToString(); BackupOptions = new BackupOptions(); return; } JObject json = JObject.Parse(File.ReadAllText(configPath)); LanguageOverride = json["LanguageOverride"]?.ToObject <Language>() ?? Language.Default; LastProfile = json["LastProfile"]?.ToObject <string>() ?? Options.DEFAULT_SETTINGS_FILENAME; UpdateGumpVersion = json["UpdateGumpVersion"]?.ToObject <string>() ?? new Version().ToString(); if (json["Backup"] == null) { BackupOptions = new BackupOptions { Enabled = !IsTesting() /*json["AutoBackupProfiles"]?.ToObject<bool>() ?? true*/, Days = json["AutoBackupProfilesDays"]?.ToObject <int>() ?? 7, LastBackup = json["AutoBackupProfilesLast"]?.ToObject <DateTime>() ?? default, Provider = new LocalBackupProvider { BackupPath = json["AutoBackupProfilesDirectory"]?.ToObject <string>() ?? BackupOptions.DefaultBackupPath } }; } else { BackupOptions = new BackupOptions(); BackupOptions.Deserialize(json, Options.CurrentOptions); } SavePasswords = json["SavePasswords"]?.ToObject <bool>() ?? false; SavePasswordsOnlyBlank = json["SavePasswordsOnlyBlank"]?.ToObject <bool>() ?? false; UserId = json["UserId"]?.ToObject <string>() ?? Guid.NewGuid().ToString(); WindowWidth = json["WindowWidth"]?.ToObject <int>() ?? 625; WindowHeight = json["WindowHeight"]?.ToObject <int>() ?? 500; UseCUOClilocLanguage = json["UseCUOClilocLanguage"]?.ToObject <bool>() ?? false; Assemblies = json["Assemblies"]?.ToObject <string[]>() ?? new string[0]; SessionId = Guid.NewGuid().ToString(); if (json["Profiles"] != null) { foreach (JToken token in json["Profiles"]) { _linkedProfiles.Add(token["Serial"]?.ToObject <int>() ?? 0, token["Profile"]?.ToObject <string>()); } } if (json["SavedPasswords"] != null) { foreach (JToken token in json["SavedPasswords"]) { SavedPasswords.Add(token["Username"]?.ToObject <string>() ?? string.Empty, Crypter.Decrypt(token["Password"]?.ToObject <string>())); } OnPasswordsChanged(); } SetLanguage(LanguageOverride); foreach (string assembly in Assemblies) { try { Assembly asm = Assembly.LoadFile(assembly); IEnumerable <MethodInfo> initializeMethods = asm.GetTypes() .Where(e => e.IsClass && e.IsPublic && e.GetMethod("Initialize", BindingFlags.Public | BindingFlags.Static, null, Type.EmptyTypes, null) != null) .Select(e => e.GetMethod("Initialize", BindingFlags.Public | BindingFlags.Static, null, Type.EmptyTypes, null)); foreach (MethodInfo initializeMethod in initializeMethods) { initializeMethod?.Invoke(null, null); } } catch (Exception) { // ignored } } OptionsLoaded?.Invoke(null, EventArgs.Empty); }