// IltSettings.cs - RynthILT's own settings (every character): which world names are Infinite // Leaftide. Lives in %APPDATA%\RynthCore\RynthILT\settings.json. // // The list was RynthAi's Settings > Misc "Server Features" (FeatureServerNames, saved with each // RynthAi profile). RynthILT keeps one list for every character; the first time a character // logs in with RynthILT, IltMigration folds that character's RynthAi list into this one. // Edited with "/ilt servers " (the Character tab's editor went with the tab, 2026-10-13; // RynthCore Options > Diagnostics lists the world names RynthCore uses). using System; using System.Collections.Generic; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; using RynthCore.Plugin.Shared; namespace RynthCore.Plugin.RynthILT.Hub; public sealed class IltSettings { public int SchemaVersion = 1; /// World-name patterns that count as Infinite Leaftide ('*' wildcard, case-insensitive). public List ServerNames = new(ServerFeatureGate.DefaultServerNames); /// The shared RynthAi files (Hub profiles, aug costs) were copied over once. public bool SharedFilesMigrated; /// /// RynthILT character folders whose copy from RynthAi failed part-way (IltMigration). Until it /// succeeds the Hub writes nothing there (a fresh file would shadow the RynthAi original and /// stop it ever being copied); the copy is retried at each login and every few minutes. /// public List PendingCharacterMigrations = new(); } /// Loads and saves ; a broken or missing file reads as the defaults. internal static class IltSettingsStore { public const string FileName = "settings.json"; /// Overridable for the tests. public static string Folder = RynthILTPlugin.SettingsRoot; public static string FilePath => Path.Combine(Folder, FileName); public static IltSettings Load() { try { if (File.Exists(FilePath)) { var s = JsonSerializer.Deserialize(File.ReadAllText(FilePath), IltHubJsonContext.Default.IltSettings); if (s != null) { s.ServerNames = ServerFeatureGate.ParseList(string.Join(",", s.ServerNames ?? new List())); if (s.ServerNames.Count == 0) s.ServerNames = new List(ServerFeatureGate.DefaultServerNames); return s; } } } catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"load {FilePath}"); } return new IltSettings(); } public static void Save(IltSettings settings) { try { string json = JsonSerializer.Serialize(settings, IltHubJsonContext.Default.IltSettings); DataWriteGuard.TrySave("RynthILT's settings", FilePath, () => { Directory.CreateDirectory(Folder); string tmp = FilePath + ".tmp"; File.WriteAllText(tmp, json); File.Move(tmp, FilePath, overwrite: true); }); } catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {FilePath}"); } } } // Source-generated System.Text.Json only (NativeAOT; never reflection-serialize plugin types: // the reflection cache keeps the old plugin generation alive across a hot reload). [JsonSerializable(typeof(IltSettings))] [JsonSerializable(typeof(IltHubState))] [JsonSerializable(typeof(List), TypeInfoPropertyName = "IltBankTransactionList")] [JsonSerializable(typeof(IltAugCostFile))] [JsonSerializable(typeof(IltLegacyProfileFlags))] [JsonSerializable(typeof(IltLegacyMiniRemote))] [JsonSerializable(typeof(IltLegacyHuds))] [JsonSourceGenerationOptions( WriteIndented = true, IncludeFields = true, PropertyNameCaseInsensitive = true)] internal partial class IltHubJsonContext : JsonSerializerContext { }