From 33f7140b75a639a8c1e1866462543f7b7165599a Mon Sep 17 00:00:00 2001
From: goat <16760685+goaaats@users.noreply.github.com>
Date: Thu, 14 Jul 2022 19:28:35 +0200
Subject: [PATCH] chore: don't persist load all api levels, banned plugins
---
.../Internal/DalamudConfiguration.cs | 10 -----
.../Interface/Internal/DalamudInterface.cs | 10 ++---
.../PluginInstaller/PluginInstallerWindow.cs | 2 +-
Dalamud/Plugin/Internal/PluginManager.cs | 40 +++++++------------
Dalamud/Plugin/Internal/Types/LocalPlugin.cs | 2 +-
5 files changed, 20 insertions(+), 44 deletions(-)
diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs
index aff8e939f..1eed6a2fa 100644
--- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs
+++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs
@@ -228,16 +228,6 @@ namespace Dalamud.Configuration.Internal
///
public string DalamudBetaKind { get; set; }
- ///
- /// Gets or sets a value indicating whether or not all plugins, regardless of API level, should be loaded.
- ///
- public bool LoadAllApiLevels { get; set; }
-
- ///
- /// Gets or sets a value indicating whether or not banned plugins should be loaded.
- ///
- public bool LoadBannedPlugins { get; set; }
-
///
/// Gets or sets a value indicating whether or not any plugin should be loaded when the game is started.
/// It is reset immediately when read.
diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs
index 28031c2a4..503771197 100644
--- a/Dalamud/Interface/Internal/DalamudInterface.cs
+++ b/Dalamud/Interface/Internal/DalamudInterface.cs
@@ -764,16 +764,14 @@ namespace Dalamud.Interface.Internal
ImGui.Separator();
- if (ImGui.MenuItem("Load all API levels (ONLY FOR DEVELOPERS!!!)", null, configuration.LoadAllApiLevels))
+ if (ImGui.MenuItem("Load all API levels (ONLY FOR DEVELOPERS!!!)", null, pluginManager.LoadAllApiLevels))
{
- configuration.LoadAllApiLevels = !configuration.LoadAllApiLevels;
- configuration.Save();
+ pluginManager.LoadAllApiLevels = !pluginManager.LoadAllApiLevels;
}
- if (ImGui.MenuItem("Load blacklisted plugins", null, configuration.LoadBannedPlugins))
+ if (ImGui.MenuItem("Load blacklisted plugins", null, pluginManager.LoadBannedPlugins))
{
- configuration.LoadBannedPlugins = !configuration.LoadBannedPlugins;
- configuration.Save();
+ pluginManager.LoadBannedPlugins = !pluginManager.LoadBannedPlugins;
}
ImGui.Separator();
diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
index 16a682106..c670c9fa9 100644
--- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
@@ -1710,7 +1710,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
var disabled = this.updateStatus == OperationStatus.InProgress || this.installStatus == OperationStatus.InProgress;
// Disable everything if the plugin is outdated
- disabled = disabled || (plugin.IsOutdated && !configuration.LoadAllApiLevels) || plugin.IsBanned;
+ disabled = disabled || (plugin.IsOutdated && !pluginManager.LoadAllApiLevels) || plugin.IsBanned;
// Disable everything if the plugin is orphaned
disabled = disabled || plugin.IsOrphaned;
diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs
index c8a18cc3f..ca99c7793 100644
--- a/Dalamud/Plugin/Internal/PluginManager.cs
+++ b/Dalamud/Plugin/Internal/PluginManager.cs
@@ -137,6 +137,16 @@ internal partial class PluginManager : IDisposable, IServiceType
///
public PluginConfigurations PluginConfigs { get; }
+ ///
+ /// Gets or sets a value indicating whether plugins of all API levels will be loaded.
+ ///
+ public bool LoadAllApiLevels { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether banned plugins will be loaded.
+ ///
+ public bool LoadBannedPlugins { get; set; }
+
///
/// Print to chat any plugin updates and whether they were successful.
///
@@ -839,28 +849,6 @@ internal partial class PluginManager : IDisposable, IServiceType
{
Log.Information($"Missing manifest: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
- continue;
- }
-
- var manifest = LocalPluginManifest.Load(manifestFile);
- if (manifest.Disabled)
- {
- Log.Information($"Disabled: cleaning up {versionDir.FullName}");
- versionDir.Delete(true);
- continue;
- }
-
- if (manifest.DalamudApiLevel < DalamudApiLevel - 1 && !this.configuration.LoadAllApiLevels)
- {
- Log.Information($"Lower API: cleaning up {versionDir.FullName}");
- versionDir.Delete(true);
- continue;
- }
-
- if (manifest.ApplicableVersion (ban.Name == manifest.InternalName || ban.Name == Hash.GetStringSha256Hash(manifest.InternalName))
+ return !this.LoadBannedPlugins && this.bannedPlugins.Any(ban => (ban.Name == manifest.InternalName || ban.Name == Hash.GetStringSha256Hash(manifest.InternalName))
&& ban.AssemblyVersion >= manifest.AssemblyVersion);
}
diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
index bb5b3d42d..f1647e217 100644
--- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
+++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
@@ -307,7 +307,7 @@ internal class LocalPlugin : IDisposable
if (this.Manifest.ApplicableVersion < startInfo.GameVersion)
throw new InvalidPluginOperationException($"Unable to load {this.Name}, no applicable version");
- if (this.Manifest.DalamudApiLevel < PluginManager.DalamudApiLevel && !configuration.LoadAllApiLevels)
+ if (this.Manifest.DalamudApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels)
throw new InvalidPluginOperationException($"Unable to load {this.Name}, incompatible API level");
if (this.Manifest.Disabled)