mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
chore: assert that bannedplugin serializes correctly
This commit is contained in:
parent
138bf2552d
commit
3c0cfc693f
2 changed files with 12 additions and 4 deletions
|
|
@ -210,7 +210,7 @@ namespace Dalamud.Interface.Internal
|
||||||
/// Opens the <see cref="DataWindow"/>.
|
/// Opens the <see cref="DataWindow"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataKind">The data kind to switch to after opening.</param>
|
/// <param name="dataKind">The data kind to switch to after opening.</param>
|
||||||
public void OpenDataWindow(string dataKind = null)
|
public void OpenDataWindow(string? dataKind = null)
|
||||||
{
|
{
|
||||||
this.dataWindow.IsOpen = true;
|
this.dataWindow.IsOpen = true;
|
||||||
if (dataKind != null && this.dataWindow.IsOpen)
|
if (dataKind != null && this.dataWindow.IsOpen)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
private readonly object pluginListLock = new();
|
private readonly object pluginListLock = new();
|
||||||
private readonly DirectoryInfo pluginDirectory;
|
private readonly DirectoryInfo pluginDirectory;
|
||||||
private readonly DirectoryInfo devPluginDirectory;
|
private readonly DirectoryInfo devPluginDirectory;
|
||||||
private readonly BannedPlugin[] bannedPlugins;
|
private readonly BannedPlugin[]? bannedPlugins;
|
||||||
|
|
||||||
[ServiceManager.ServiceDependency]
|
[ServiceManager.ServiceDependency]
|
||||||
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
|
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
|
@ -78,7 +78,11 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
this.PluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(this.startInfo.ConfigurationPath) ?? string.Empty, "pluginConfigs"));
|
this.PluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(this.startInfo.ConfigurationPath) ?? string.Empty, "pluginConfigs"));
|
||||||
|
|
||||||
var bannedPluginsJson = File.ReadAllText(Path.Combine(this.startInfo.AssetDirectory!, "UIRes", "bannedplugin.json"));
|
var bannedPluginsJson = File.ReadAllText(Path.Combine(this.startInfo.AssetDirectory!, "UIRes", "bannedplugin.json"));
|
||||||
this.bannedPlugins = JsonConvert.DeserializeObject<BannedPlugin[]>(bannedPluginsJson) ?? Array.Empty<BannedPlugin>();
|
this.bannedPlugins = JsonConvert.DeserializeObject<BannedPlugin[]>(bannedPluginsJson);
|
||||||
|
if (this.bannedPlugins == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Couldn't deserialize banned plugins manifest.");
|
||||||
|
}
|
||||||
|
|
||||||
this.ApplyPatches();
|
this.ApplyPatches();
|
||||||
}
|
}
|
||||||
|
|
@ -846,7 +850,7 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manifest.DalamudApiLevel < DalamudApiLevel - 1 && !configuration.LoadAllApiLevels)
|
if (manifest.DalamudApiLevel < DalamudApiLevel - 1 && !this.configuration.LoadAllApiLevels)
|
||||||
{
|
{
|
||||||
Log.Information($"Lower API: cleaning up {versionDir.FullName}");
|
Log.Information($"Lower API: cleaning up {versionDir.FullName}");
|
||||||
versionDir.Delete(true);
|
versionDir.Delete(true);
|
||||||
|
|
@ -1060,6 +1064,8 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
/// <returns>A value indicating whether the plugin/manifest has been banned.</returns>
|
/// <returns>A value indicating whether the plugin/manifest has been banned.</returns>
|
||||||
public bool IsManifestBanned(PluginManifest manifest)
|
public bool IsManifestBanned(PluginManifest manifest)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(this.bannedPlugins != null, "this.bannedPlugins != null");
|
||||||
|
|
||||||
return !this.configuration.LoadBannedPlugins && this.bannedPlugins.Any(ban => (ban.Name == manifest.InternalName || ban.Name == Hash.GetStringSha256Hash(manifest.InternalName))
|
return !this.configuration.LoadBannedPlugins && this.bannedPlugins.Any(ban => (ban.Name == manifest.InternalName || ban.Name == Hash.GetStringSha256Hash(manifest.InternalName))
|
||||||
&& ban.AssemblyVersion >= manifest.AssemblyVersion);
|
&& ban.AssemblyVersion >= manifest.AssemblyVersion);
|
||||||
}
|
}
|
||||||
|
|
@ -1071,6 +1077,8 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
/// <returns>The reason of the ban, if any.</returns>
|
/// <returns>The reason of the ban, if any.</returns>
|
||||||
public string GetBanReason(PluginManifest manifest)
|
public string GetBanReason(PluginManifest manifest)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(this.bannedPlugins != null, "this.bannedPlugins != null");
|
||||||
|
|
||||||
return this.bannedPlugins.LastOrDefault(ban => ban.Name == manifest.InternalName).Reason;
|
return this.bannedPlugins.LastOrDefault(ban => ban.Name == manifest.InternalName).Reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue