From 2302f15c84a07d8c6681eff0de7cea24589ada96 Mon Sep 17 00:00:00 2001 From: Raymond Date: Thu, 15 Jul 2021 21:06:33 -0400 Subject: [PATCH 1/2] Disable unloaded dev plugins at boot --- Dalamud/Plugin/Internal/PluginManager.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 6cda9827a..91d43a2f7 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -455,6 +455,10 @@ namespace Dalamud.Plugin.Internal var devPlugin = new LocalDevPlugin(this.dalamud, dllFile, manifest); loadPlugin &= !isBoot || devPlugin.StartOnBoot; + // If we're not loading it, make sure it's disabled + if (!loadPlugin && !devPlugin.IsDisabled) + devPlugin.Disable(); + plugin = devPlugin; } else @@ -479,14 +483,17 @@ namespace Dalamud.Plugin.Internal } catch (Exception ex) { - // Dev plugins always get added to the list so they can be fiddled with in the UI if (plugin.IsDev) { + // Dev plugins always get added to the list so they can be fiddled with in the UI Log.Information(ex, $"Dev plugin failed to load, adding anyways: {dllFile.Name}"); + plugin.Disable(); // Disable here, otherwise you can't enable+load later } else if (plugin.Manifest.DalamudApiLevel < DalamudApiLevel) { + // Out of date plugins get added so they can be updated. Log.Information(ex, $"Plugin was outdated, adding anyways: {dllFile.Name}"); + // plugin.Disable(); // Don't disable, or it gets deleted next boot. } else { From bfc7d634cee80b38213cdab05ba41d21ffaabaa3 Mon Sep 17 00:00:00 2001 From: Raymond Date: Thu, 15 Jul 2021 21:27:38 -0400 Subject: [PATCH 2/2] Ref to Config.DevSettings was not updating --- .../Internal/DalamudConfiguration.cs | 7 +++++-- .../Configuration/Internal/DevPluginSettings.cs | 15 --------------- Dalamud/Plugin/Internal/LocalDevPlugin.cs | 10 ++-------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index 2188b553e..ed10572e4 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -85,9 +85,12 @@ namespace Dalamud.Configuration.Internal public List HiddenPluginInternalName { get; set; } = new(); /// - /// Gets or sets a list of additional settings for devPlugins. + /// Gets or sets a list of additional settings for devPlugins. The key is the absolute path + /// to the plugin DLL. This is automatically generated for any plugins in the devPlugins folder. + /// However by specifiying this value manually, you can add arbitrary files outside the normal + /// file paths. /// - public List DevPluginSettings { get; set; } = new(); + public Dictionary DevPluginSettings { get; set; } = new(); /// /// Gets or sets the global UI scale. diff --git a/Dalamud/Configuration/Internal/DevPluginSettings.cs b/Dalamud/Configuration/Internal/DevPluginSettings.cs index fc6557da6..17350cba0 100644 --- a/Dalamud/Configuration/Internal/DevPluginSettings.cs +++ b/Dalamud/Configuration/Internal/DevPluginSettings.cs @@ -5,21 +5,6 @@ namespace Dalamud.Configuration.Internal /// internal sealed class DevPluginSettings { - /// - /// Initializes a new instance of the class. - /// - /// Filename of the DLL representing this plugin. - public DevPluginSettings(string dllFile) - { - this.DllFile = dllFile; - } - - /// - /// Gets or sets the path to a plugin DLL. This is automatically generated for any plugins in the devPlugins folder. However by - /// specifiying this value manually, you can add arbitrary files outside the normal file paths. - /// - public string DllFile { get; set; } - /// /// Gets or sets a value indicating whether this plugin should automatically start when Dalamud boots up. /// diff --git a/Dalamud/Plugin/Internal/LocalDevPlugin.cs b/Dalamud/Plugin/Internal/LocalDevPlugin.cs index 58390270b..77b3be253 100644 --- a/Dalamud/Plugin/Internal/LocalDevPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalDevPlugin.cs @@ -33,18 +33,12 @@ namespace Dalamud.Plugin.Internal public LocalDevPlugin(Dalamud dalamud, FileInfo dllFile, LocalPluginManifest manifest) : base(dalamud, dllFile, manifest) { - // base is called first, ensuring that this is a valid plugin assembly - var devSettings = dalamud.Configuration.DevPluginSettings.FirstOrDefault(cfg => cfg.DllFile == dllFile.FullName); - - if (devSettings == default) + if (!dalamud.Configuration.DevPluginSettings.TryGetValue(dllFile.FullName, out this.devSettings)) { - devSettings = new DevPluginSettings(dllFile.FullName); - dalamud.Configuration.DevPluginSettings.Add(devSettings); + dalamud.Configuration.DevPluginSettings[dllFile.FullName] = this.devSettings = new DevPluginSettings(); dalamud.Configuration.Save(); } - this.devSettings = devSettings; - if (this.AutomaticReload) { this.EnableReloading();