diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
index 75037704b..faf8e022f 100644
--- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
@@ -12,6 +12,7 @@ using CheapLoc;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Interface.Windowing;
+using Dalamud.Plugin;
using Dalamud.Plugin.Internal;
using Dalamud.Plugin.Internal.Exceptions;
using Dalamud.Plugin.Internal.Types;
@@ -526,7 +527,7 @@ namespace Dalamud.Interface.Internal.Windows
{
this.installStatus = OperationStatus.InProgress;
- Task.Run(() => this.dalamud.PluginManager.InstallPlugin(manifest, useTesting))
+ Task.Run(() => this.dalamud.PluginManager.InstallPlugin(manifest, useTesting, PluginLoadReason.Installer))
.ContinueWith(task =>
{
// There is no need to set as Complete for an individual plugin installation
@@ -743,7 +744,7 @@ namespace Dalamud.Interface.Internal.Windows
if (!enableTask.Result)
return;
- var loadTask = Task.Run(() => plugin.Load())
+ var loadTask = Task.Run(() => plugin.Load(PluginLoadReason.Installer))
.ContinueWith(this.DisplayErrorContinuation, Locs.ErrorModal_LoadFail(plugin.Name));
loadTask.Wait();
diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs
index 8dfced79a..9ab55d24c 100644
--- a/Dalamud/Plugin/DalamudPluginInterface.cs
+++ b/Dalamud/Plugin/DalamudPluginInterface.cs
@@ -36,7 +36,8 @@ namespace Dalamud.Plugin
/// The dalamud instance to expose.
/// The internal name of the plugin.
/// The equivalent of what Assembly.GetExecutingAssembly().Location should return.
- internal DalamudPluginInterface(Dalamud dalamud, string pluginName, string assemblyLocation)
+ /// The reason the plugin was loaded.
+ internal DalamudPluginInterface(Dalamud dalamud, string pluginName, string assemblyLocation, PluginLoadReason reason)
{
this.CommandManager = dalamud.CommandManager;
this.Framework = dalamud.Framework;
@@ -50,6 +51,7 @@ namespace Dalamud.Plugin
this.pluginName = pluginName;
this.configs = dalamud.PluginManager.PluginConfigs;
this.AssemblyLocation = assemblyLocation;
+ this.Reason = reason;
this.GeneralChatType = this.dalamud.Configuration.GeneralChatType;
this.Sanitizer = new Sanitizer(this.Data.Language);
@@ -81,6 +83,11 @@ namespace Dalamud.Plugin
///
public event LanguageChangedDelegate OnLanguageChanged;
+ ///
+ /// Gets the reason this plugin was loaded.
+ ///
+ public PluginLoadReason Reason { get; }
+
///
/// Gets the plugin assembly location.
///
diff --git a/Dalamud/Plugin/Internal/LocalPlugin.cs b/Dalamud/Plugin/Internal/LocalPlugin.cs
index e14153fc6..9df84d35b 100644
--- a/Dalamud/Plugin/Internal/LocalPlugin.cs
+++ b/Dalamud/Plugin/Internal/LocalPlugin.cs
@@ -140,7 +140,7 @@ namespace Dalamud.Plugin.Internal
public PluginState State { get; protected set; } = PluginState.Unloaded;
///
- /// Gets the AssemblyName plugin, populated during .
+ /// Gets the AssemblyName plugin, populated during .
///
/// Plugin type.
public AssemblyName AssemblyName { get; private set; } = null;
@@ -188,8 +188,9 @@ namespace Dalamud.Plugin.Internal
///
/// Load this plugin.
///
+ /// The reason why this plugin is being loaded.
/// Load while reloading.
- public void Load(bool reloading = false)
+ public void Load(PluginLoadReason reason, bool reloading = false)
{
// Allowed: Unloaded
switch (this.State)
@@ -271,7 +272,7 @@ namespace Dalamud.Plugin.Internal
this.Manifest.Save(this.manifestFile);
}
- this.DalamudInterface = new DalamudPluginInterface(this.dalamud, this.pluginAssembly.GetName().Name, this.DllFile.FullName);
+ this.DalamudInterface = new DalamudPluginInterface(this.dalamud, this.pluginAssembly.GetName().Name, this.DllFile.FullName, reason);
if (this.IsDev)
{
@@ -365,7 +366,7 @@ namespace Dalamud.Plugin.Internal
public void Reload()
{
this.Unload(true);
- this.Load(true);
+ this.Load(PluginLoadReason.Reload, true);
}
///
diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs
index 4003ae02d..1576d48ba 100644
--- a/Dalamud/Plugin/Internal/PluginManager.cs
+++ b/Dalamud/Plugin/Internal/PluginManager.cs
@@ -192,7 +192,7 @@ namespace Dalamud.Plugin.Internal
{
try
{
- this.LoadPlugin(pluginDef.DllFile, pluginDef.Manifest, pluginDef.IsDev, isBoot: true);
+ this.LoadPlugin(pluginDef.DllFile, pluginDef.Manifest, PluginLoadReason.Boot, pluginDef.IsDev, isBoot: true);
}
catch (InvalidPluginException)
{
@@ -230,8 +230,7 @@ namespace Dalamud.Plugin.Internal
{
try
{
- plugin.Unload();
- plugin.Load();
+ plugin.Reload();
}
catch (Exception ex)
{
@@ -300,7 +299,7 @@ namespace Dalamud.Plugin.Internal
try
{
// Add them to the list and let the user decide, nothing is auto-loaded.
- this.LoadPlugin(dllFile, manifest, isDev: true, doNotLoad: true);
+ this.LoadPlugin(dllFile, manifest, PluginLoadReason.Installer, isDev: true, doNotLoad: true);
listChanged = true;
}
catch (InvalidPluginException)
@@ -322,7 +321,8 @@ namespace Dalamud.Plugin.Internal
///
/// The plugin definition.
/// If the testing version should be used.
- public void InstallPlugin(RemotePluginManifest repoManifest, bool useTesting)
+ /// The reason this plugin was loaded.
+ public void InstallPlugin(RemotePluginManifest repoManifest, bool useTesting, PluginLoadReason reason)
{
Log.Debug($"Installing plugin {repoManifest.Name} (testing={useTesting})");
@@ -413,7 +413,7 @@ namespace Dalamud.Plugin.Internal
Log.Information($"Installed plugin {manifest.Name} (testing={useTesting})");
- this.LoadPlugin(dllFile, manifest);
+ this.LoadPlugin(dllFile, manifest, reason);
this.NotifyInstalledPluginsChanged();
}
@@ -423,10 +423,11 @@ namespace Dalamud.Plugin.Internal
///
/// The associated with the main assembly of this plugin.
/// The already loaded definition, if available.
+ /// The reason this plugin was loaded.
/// If this plugin should support development features.
/// If this plugin is being loaded at boot.
/// Don't load the plugin, just don't do it.
- public void LoadPlugin(FileInfo dllFile, LocalPluginManifest manifest, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
+ public void LoadPlugin(FileInfo dllFile, LocalPluginManifest manifest, PluginLoadReason reason, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
{
var name = manifest?.Name ?? dllFile.Name;
var loadPlugin = !doNotLoad;
@@ -454,7 +455,7 @@ namespace Dalamud.Plugin.Internal
if (plugin.IsDisabled)
plugin.Enable();
- plugin.Load();
+ plugin.Load(reason);
}
catch (InvalidPluginException)
{
@@ -653,7 +654,7 @@ namespace Dalamud.Plugin.Internal
try
{
- this.InstallPlugin(metadata.UpdateManifest, metadata.UseTesting);
+ this.InstallPlugin(metadata.UpdateManifest, metadata.UseTesting, PluginLoadReason.Update);
listChanged = true;
}
catch (Exception ex)
diff --git a/Dalamud/Plugin/PluginLoadReason.cs b/Dalamud/Plugin/PluginLoadReason.cs
new file mode 100644
index 000000000..846525b0f
--- /dev/null
+++ b/Dalamud/Plugin/PluginLoadReason.cs
@@ -0,0 +1,33 @@
+namespace Dalamud.Plugin
+{
+ ///
+ /// This enum reflects reasons for loading a plugin.
+ ///
+ public enum PluginLoadReason
+ {
+ ///
+ /// We don't know why this plugin was loaded.
+ ///
+ Unknown,
+
+ ///
+ /// This plugin was loaded because it was installed with the plugin installer.
+ ///
+ Installer,
+
+ ///
+ /// This plugin was loaded because it was just updated.
+ ///
+ Update,
+
+ ///
+ /// This plugin was loaded because it was told to reload.
+ ///
+ Reload,
+
+ ///
+ /// This plugin was loaded because the game was started or Dalamud was reinjected.
+ ///
+ Boot,
+ }
+}