Fix PluginWatcher properly this time maybe
This commit is contained in:
@@ -182,9 +182,7 @@ public sealed class NoSnapService : IHostedService, IMediatorSubscriber
|
||||
|
||||
foreach (var pluginName in _listOfPlugins.Keys)
|
||||
{
|
||||
var plugin = _pluginInterface.InstalledPlugins.FirstOrDefault(p => p.InternalName.Equals(pluginName, StringComparison.Ordinal));
|
||||
if (plugin?.IsLoaded ?? false)
|
||||
_listOfPlugins[pluginName] = true;
|
||||
_listOfPlugins[pluginName] = PluginWatcherService.GetInitialPluginState(_pluginInterface, pluginName)?.IsLoaded ?? false;
|
||||
Mediator.SubscribeKeyed<PluginChangeMessage>(this, pluginName, (msg) =>
|
||||
{
|
||||
_listOfPlugins[pluginName] = msg.IsLoaded;
|
||||
|
||||
@@ -88,6 +88,25 @@ public class PluginWatcherService : MediatorSubscriberBase
|
||||
Update(publish: false);
|
||||
}
|
||||
|
||||
public static PluginChangeMessage? GetInitialPluginState(IDalamudPluginInterface pi, string internalName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var plugin = pi.InstalledPlugins.Where(p => p.InternalName.Equals(internalName, StringComparison.Ordinal))
|
||||
.OrderBy(p => (!p.IsLoaded, p.Version))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (plugin == null)
|
||||
return null;
|
||||
|
||||
return new PluginChangeMessage(plugin.InternalName, plugin.Version, plugin.IsLoaded);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update(bool publish = true)
|
||||
{
|
||||
if (!ExposedPluginsEqual(_pluginInterface.InstalledPlugins, _prevInstalledPluginState))
|
||||
|
||||
Reference in New Issue
Block a user