diff --git a/NominaOcculta/NameRepository.cs b/NominaOcculta/NameRepository.cs index 8547ea1..dee9220 100755 --- a/NominaOcculta/NameRepository.cs +++ b/NominaOcculta/NameRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using Dalamud.Game; using Lumina.Excel.GeneratedSheets; @@ -20,6 +21,7 @@ namespace NominaOcculta { internal IReadOnlyDictionary ReadOnlyLastSeenInfo => this.LastSeenInfo; private readonly int _numRaces; + private readonly Stopwatch _loadSheetWatch = new(); internal bool Initialised; @@ -48,6 +50,13 @@ namespace NominaOcculta { } private void OnFrameworkUpdate(Framework framework) { + // The game unloads the CharaMakeName sheet after logging in. + // We need this sheet to generate names, so we load it again. + if (this._loadSheetWatch.IsRunning && this._loadSheetWatch.Elapsed > TimeSpan.FromSeconds(3)) { + this.Plugin.Functions.LoadSheet("CharaMakeName"); + this._loadSheetWatch.Reset(); + } + // The in-game name generator will generate duplicate names if it is given // identical parameters on the same frame. Instead, we will fill up a queue // with 100 names (the maximum amount of players in the object table) for @@ -76,10 +85,7 @@ namespace NominaOcculta { } private void OnLogin(object? sender, EventArgs e) { - // The game unloads the CharaMakeName sheet after logging in. - // We need this sheet to generate names, so we load it again. - - this.Plugin.Functions.LoadSheet("CharaMakeName"); + this._loadSheetWatch.Restart(); } ///