mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 20:54:16 +01:00
treat banned plugins like out of date, dont load but allow update
This commit is contained in:
parent
0cfbc70286
commit
c34d4dfd87
3 changed files with 36 additions and 1 deletions
22
Dalamud/Plugin/Internal/Exceptions/BannedPluginException.cs
Normal file
22
Dalamud/Plugin/Internal/Exceptions/BannedPluginException.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
namespace Dalamud.Plugin.Internal.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This represents a banned plugin that attempted an operation.
|
||||||
|
/// </summary>
|
||||||
|
internal class BannedPluginException : PluginException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="BannedPluginException"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The message describing the invalid operation.</param>
|
||||||
|
public BannedPluginException(string message)
|
||||||
|
{
|
||||||
|
this.Message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the message describing the invalid operation.
|
||||||
|
/// </summary>
|
||||||
|
public override string Message { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -222,6 +222,9 @@ namespace Dalamud.Plugin.Internal
|
||||||
throw new InvalidPluginOperationException($"Unable to load {this.Name}, unload previously faulted, restart Dalamud");
|
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)
|
if (this.Manifest.ApplicableVersion < startInfo.GameVersion)
|
||||||
throw new InvalidPluginOperationException($"Unable to load {this.Name}, no applicable version");
|
throw new InvalidPluginOperationException($"Unable to load {this.Name}, no applicable version");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -548,6 +548,11 @@ namespace Dalamud.Plugin.Internal
|
||||||
PluginLocations.Remove(plugin.AssemblyName.FullName);
|
PluginLocations.Remove(plugin.AssemblyName.FullName);
|
||||||
throw;
|
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (plugin.IsDev)
|
if (plugin.IsDev)
|
||||||
|
|
@ -936,7 +941,12 @@ namespace Dalamud.Plugin.Internal
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsManifestBanned(PluginManifest manifest)
|
/// <summary>
|
||||||
|
/// Determine if a plugin has been banned by inspecting the manifest.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="manifest">Manifest to inspect.</param>
|
||||||
|
/// <returns>A value indicating whether the plugin/manifest has been banned.</returns>
|
||||||
|
public bool IsManifestBanned(PluginManifest manifest)
|
||||||
{
|
{
|
||||||
return this.bannedPlugins.Any(ban => ban.Name == manifest.InternalName && ban.AssemblyVersion == manifest.AssemblyVersion);
|
return this.bannedPlugins.Any(ban => ban.Name == manifest.InternalName && ban.AssemblyVersion == manifest.AssemblyVersion);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue