From 089f0c9495122bfc9e6712e4c33f7c20f7c98e0b Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Mon, 4 Aug 2025 03:15:43 +0200 Subject: [PATCH] Add ActivePluginsChangedEventArgs --- .../Plugin/ActivePluginsChangedEventArgs.cs | 19 +++++++++++++++++++ Dalamud/Plugin/DalamudPluginInterface.cs | 7 +++---- Dalamud/Plugin/IDalamudPluginInterface.cs | 7 +++---- Dalamud/Plugin/Internal/PluginManager.cs | 4 +--- 4 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 Dalamud/Plugin/ActivePluginsChangedEventArgs.cs diff --git a/Dalamud/Plugin/ActivePluginsChangedEventArgs.cs b/Dalamud/Plugin/ActivePluginsChangedEventArgs.cs new file mode 100644 index 000000000..4551cf752 --- /dev/null +++ b/Dalamud/Plugin/ActivePluginsChangedEventArgs.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Dalamud.Plugin; + +/// +/// Contains data about changes to the list of active plugins. +/// +public class ActivePluginsChangedEventArgs(PluginListInvalidationKind kind, IEnumerable affectedInternalNames) : EventArgs +{ + /// + /// Gets the invalidation kind that caused this event to be fired. + /// + public PluginListInvalidationKind Kind { get; } = kind; + + /// + /// Gets the InternalNames of affected plugins. + /// + public IEnumerable AffectedInternalNames { get; } = affectedInternalNames; +} diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index e1c6b7830..561489def 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -523,15 +523,14 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa /// /// Dispatch the active plugins changed event. /// - /// What action caused this event to be fired. - /// If this plugin was affected by the change. - internal void NotifyActivePluginsChanged(PluginListInvalidationKind kind, bool affectedThisPlugin) + /// The event arguments containing information about the change. + internal void NotifyActivePluginsChanged(ActivePluginsChangedEventArgs args) { foreach (var action in Delegate.EnumerateInvocationList(this.ActivePluginsChanged)) { try { - action(kind, affectedThisPlugin); + action(args); } catch (Exception ex) { diff --git a/Dalamud/Plugin/IDalamudPluginInterface.cs b/Dalamud/Plugin/IDalamudPluginInterface.cs index 5b7c3836e..ce0abbd26 100644 --- a/Dalamud/Plugin/IDalamudPluginInterface.cs +++ b/Dalamud/Plugin/IDalamudPluginInterface.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Threading.Tasks; @@ -32,9 +32,8 @@ public interface IDalamudPluginInterface /// /// Delegate for events that listen to changes to the list of active plugins. /// - /// What action caused this event to be fired. - /// If this plugin was affected by the change. - public delegate void ActivePluginsChangedDelegate(PluginListInvalidationKind kind, bool affectedThisPlugin); + /// The event arguments containing information about the change. + public delegate void ActivePluginsChangedDelegate(ActivePluginsChangedEventArgs args); /// /// Event that gets fired when loc is changed diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 5cd5eadd1..6f840fc79 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -1307,9 +1307,7 @@ internal class PluginManager : IInternalDisposableService continue; installedPlugin.DalamudInterface.NotifyActivePluginsChanged( - kind, - // ReSharper disable once PossibleMultipleEnumeration - affectedInternalNames.Contains(installedPlugin.Manifest.InternalName)); + new ActivePluginsChangedEventArgs(kind, affectedInternalNames)); } }