feat: add support for bannedplugin.json to catch failing plugins

This commit is contained in:
goat 2021-04-12 00:55:36 +02:00
parent 67dd9fbf9c
commit d53bc4b1cb
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -29,6 +29,8 @@ namespace Dalamud.Plugin
private readonly Type interfaceType = typeof(IDalamudPlugin);
private readonly List<BannedPlugin> bannedPlugins;
/// <summary>
/// Initializes a new instance of the <see cref="PluginManager"/> class.
/// </summary>
@ -48,6 +50,9 @@ namespace Dalamud.Plugin
this.pluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(dalamud.StartInfo.ConfigurationPath), "pluginConfigs"));
this.bannedPlugins = JsonConvert.DeserializeObject<List<BannedPlugin>>(
File.ReadAllText(Path.Combine(this.dalamud.StartInfo.AssetDirectory, "UIRes", "bannedplugin.json")));
// Try to load missing assemblies from the local directory of the requesting assembly
// This would usually be implicit when using Assembly.Load(), but Assembly.LoadFile() doesn't do it...
// This handler should only be invoked on things that fail regular lookups, but it *is* global to this appdomain
@ -317,6 +322,13 @@ namespace Dalamud.Plugin
DalamudApiLevel = DalamudApiLevel,
};
if (this.bannedPlugins.Any(x => x.Name == pluginDef.InternalName &&
x.AssemblyVersion == pluginDef.AssemblyVersion))
{
Log.Error($"[PLUGINM] Banned plugin {pluginDef.InternalName} with {pluginDef.AssemblyVersion}");
return false;
}
if (pluginDef.InternalName == "PingPlugin" && pluginDef.AssemblyVersion == "1.11.0.0")
{
Log.Error("Banned PingPlugin");
@ -366,5 +378,12 @@ namespace Dalamud.Plugin
this.UnloadPlugins();
this.LoadPlugins();
}
private class BannedPlugin
{
public string Name { get; set; }
public string AssemblyVersion { get; set; }
}
}
}