diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs index fff158c..c988006 100644 --- a/MareSynchronos/Plugin.cs +++ b/MareSynchronos/Plugin.cs @@ -34,10 +34,21 @@ public sealed class Plugin : IDalamudPlugin private readonly CancellationTokenSource _pluginCts = new(); private readonly Task _hostBuilderRunTask; + public static Plugin Self; + public Action _realOnFrameworkUpdate = null; + + // Proxy function in the LoporritSync namespace to avoid confusion in /xlstats + public void OnFrameworkUpdate(IFramework framework) + { + if (_realOnFrameworkUpdate != null) + _realOnFrameworkUpdate(framework); + } + public Plugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager, IDataManager gameData, IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui, IGameGui gameGui, IDtrBar dtrBar, IPluginLog pluginLog, ITargetManager targetManager) { + Plugin.Self = this; _hostBuilderRunTask = new HostBuilder() .UseContentRoot(pluginInterface.ConfigDirectory.FullName) .ConfigureLogging(lb => diff --git a/MareSynchronos/Services/DalamudUtilService.cs b/MareSynchronos/Services/DalamudUtilService.cs index aa7a69d..745b891 100644 --- a/MareSynchronos/Services/DalamudUtilService.cs +++ b/MareSynchronos/Services/DalamudUtilService.cs @@ -291,7 +291,10 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber public Task StartAsync(CancellationToken cancellationToken) { - _framework.Update += FrameworkOnUpdate; +#pragma warning disable S2696 // Instance members should not write to "static" fields + LoporritSync.Plugin.Self._realOnFrameworkUpdate = this.FrameworkOnUpdate; +#pragma warning restore S2696 + _framework.Update += LoporritSync.Plugin.Self.OnFrameworkUpdate; if (IsLoggedIn) { _classJobId = _clientState.LocalPlayer!.ClassJob.Id; @@ -305,7 +308,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber _logger.LogTrace("Stopping {type}", GetType()); Mediator.UnsubscribeAll(this); - _framework.Update -= FrameworkOnUpdate; + _framework.Update -= LoporritSync.Plugin.Self.OnFrameworkUpdate; return Task.CompletedTask; }