diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs
index da5b28a19..cc4bd4d82 100644
--- a/Dalamud/Game/ChatHandlers.cs
+++ b/Dalamud/Game/ChatHandlers.cs
@@ -294,7 +294,7 @@ public class ChatHandlers : IServiceType
this.hasAutoUpdatedPlugins = true;
- Task.Run(() => pluginManager.UpdatePluginsAsync(true, !this.configuration.AutoUpdatePlugins)).ContinueWith(task =>
+ Task.Run(() => pluginManager.UpdatePluginsAsync(true, !this.configuration.AutoUpdatePlugins, true)).ContinueWith(task =>
{
if (task.IsFaulted)
{
diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs
index 8f97c7d82..7e3f0eacd 100644
--- a/Dalamud/Plugin/DalamudPluginInterface.cs
+++ b/Dalamud/Plugin/DalamudPluginInterface.cs
@@ -88,11 +88,23 @@ public sealed class DalamudPluginInterface : IDisposable
/// The new language code.
public delegate void LanguageChangedDelegate(string langCode);
+ ///
+ /// 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);
+
///
/// Event that gets fired when loc is changed
///
public event LanguageChangedDelegate LanguageChanged;
+ ///
+ /// Event that is fired when the active list of plugins is changed.
+ ///
+ public event ActivePluginsChangedDelegate ActivePluginsChanged;
+
///
/// Gets the reason this plugin was loaded.
///
@@ -472,6 +484,16 @@ public sealed class DalamudPluginInterface : IDisposable
// ignored
}
+ ///
+ /// 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)
+ {
+ this.ActivePluginsChanged.Invoke(kind, affectedThisPlugin);
+ }
+
private void OnLocalizationChanged(string langCode)
{
this.UiLanguage = langCode;
diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs
index 608c6a499..d6db29c0e 100644
--- a/Dalamud/Plugin/Internal/PluginManager.cs
+++ b/Dalamud/Plugin/Internal/PluginManager.cs
@@ -1063,8 +1063,9 @@ Thanks and have fun!";
///
/// Ignore disabled plugins.
/// Perform a dry run, don't install anything.
+ /// If this action was performed as part of an auto-update.
/// Success or failure and a list of updated plugin metadata.
- public async Task> UpdatePluginsAsync(bool ignoreDisabled, bool dryRun)
+ public async Task> UpdatePluginsAsync(bool ignoreDisabled, bool dryRun, bool autoUpdate = false)
{
Log.Information("Starting plugin update");
@@ -1089,6 +1090,9 @@ Thanks and have fun!";
}
this.NotifyInstalledPluginsChanged();
+ this.NotifyPluginsForStateChange(
+ autoUpdate ? PluginListInvalidationKind.AutoUpdate : PluginListInvalidationKind.Update,
+ updatedList.Select(x => x.InternalName));
Log.Information("Plugin update OK.");
@@ -1391,6 +1395,20 @@ Thanks and have fun!";
this.OnInstalledPluginsChanged?.InvokeSafely();
}
+ private void NotifyPluginsForStateChange(PluginListInvalidationKind kind, IEnumerable affectedInternalNames)
+ {
+ foreach (var installedPlugin in this.InstalledPlugins)
+ {
+ if (!installedPlugin.IsLoaded || installedPlugin.DalamudInterface == null)
+ continue;
+
+ installedPlugin.DalamudInterface.NotifyActivePluginsChanged(
+ kind,
+ // ReSharper disable once PossibleMultipleEnumeration
+ affectedInternalNames.Contains(installedPlugin.Manifest.InternalName));
+ }
+ }
+
private static class Locs
{
public static string DalamudPluginUpdateSuccessful(string name, Version version) => Loc.Localize("DalamudPluginUpdateSuccessful", " 》 {0} updated to v{1}.").Format(name, version);
diff --git a/Dalamud/Plugin/PluginListInvalidationKind.cs b/Dalamud/Plugin/PluginListInvalidationKind.cs
new file mode 100644
index 000000000..4e7782703
--- /dev/null
+++ b/Dalamud/Plugin/PluginListInvalidationKind.cs
@@ -0,0 +1,17 @@
+namespace Dalamud.Plugin;
+
+///
+/// Causes for a change to the plugin list.
+///
+public enum PluginListInvalidationKind
+{
+ ///
+ /// An installer-initiated update reloaded plugins.
+ ///
+ Update,
+
+ ///
+ /// An auto-update reloaded plugins.
+ ///
+ AutoUpdate,
+}