diff --git a/Dalamud/Plugin/Internal/Exceptions/BannedPluginException.cs b/Dalamud/Plugin/Internal/Exceptions/BannedPluginException.cs new file mode 100644 index 000000000..e4418b6d3 --- /dev/null +++ b/Dalamud/Plugin/Internal/Exceptions/BannedPluginException.cs @@ -0,0 +1,22 @@ +namespace Dalamud.Plugin.Internal.Exceptions +{ + /// + /// This represents a banned plugin that attempted an operation. + /// + internal class BannedPluginException : PluginException + { + /// + /// Initializes a new instance of the class. + /// + /// The message describing the invalid operation. + public BannedPluginException(string message) + { + this.Message = message; + } + + /// + /// Gets the message describing the invalid operation. + /// + public override string Message { get; } + } +} diff --git a/Dalamud/Plugin/Internal/LocalPlugin.cs b/Dalamud/Plugin/Internal/LocalPlugin.cs index 0d9985602..e5f26c418 100644 --- a/Dalamud/Plugin/Internal/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalPlugin.cs @@ -222,6 +222,9 @@ namespace Dalamud.Plugin.Internal throw new InvalidPluginOperationException($"Unable to load {this.Name}, unload previously faulted, restart Dalamud"); } + if (pluginManager.IsManifestBanned(this.Manifest)) + throw new BannedPluginException($"Unable to load {this.Name}, banned"); + if (this.Manifest.ApplicableVersion < startInfo.GameVersion) throw new InvalidPluginOperationException($"Unable to load {this.Name}, no applicable version"); diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 47e3ca478..5b87abbb1 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -548,6 +548,11 @@ namespace Dalamud.Plugin.Internal PluginLocations.Remove(plugin.AssemblyName.FullName); throw; } + catch (BannedPluginException) + { + // Out of date plugins get added so they can be updated. + Log.Information($"Plugin was banned, adding anyways: {dllFile.Name}"); + } catch (Exception ex) { if (plugin.IsDev) @@ -936,7 +941,12 @@ namespace Dalamud.Plugin.Internal return true; } - private bool IsManifestBanned(PluginManifest manifest) + /// + /// Determine if a plugin has been banned by inspecting the manifest. + /// + /// Manifest to inspect. + /// A value indicating whether the plugin/manifest has been banned. + public bool IsManifestBanned(PluginManifest manifest) { return this.bannedPlugins.Any(ban => ban.Name == manifest.InternalName && ban.AssemblyVersion == manifest.AssemblyVersion); }