Add MinimumDalamudVersion to manifest, validate at install, update and load (#2248)

This commit is contained in:
goat 2025-04-28 21:09:40 +02:00 committed by GitHub
commit f5d93fb08e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 58 additions and 17 deletions

View file

@ -1760,6 +1760,7 @@ internal class PluginManager : IInternalDisposableService
var updates = this.AvailablePlugins
.Where(remoteManifest => plugin.Manifest.InternalName == remoteManifest.InternalName)
.Where(remoteManifest => plugin.Manifest.InstalledFromUrl == remoteManifest.SourceRepo.PluginMasterUrl || !remoteManifest.SourceRepo.IsThirdParty)
.Where(remoteManifest => remoteManifest.MinimumDalamudVersion == null || Util.AssemblyVersionParsed >= remoteManifest.MinimumDalamudVersion)
.Where(remoteManifest =>
{
var useTesting = this.UseTesting(remoteManifest);

View file

@ -15,6 +15,7 @@ using Dalamud.Plugin.Internal.Exceptions;
using Dalamud.Plugin.Internal.Loader;
using Dalamud.Plugin.Internal.Profiles;
using Dalamud.Plugin.Internal.Types.Manifest;
using Dalamud.Utility;
namespace Dalamud.Plugin.Internal.Types;
@ -313,6 +314,9 @@ internal class LocalPlugin : IAsyncDisposable
if (!this.CheckPolicy())
throw new PluginPreconditionFailedException($"Unable to load {this.Name} as a load policy forbids it");
if (this.Manifest.MinimumDalamudVersion != null && this.Manifest.MinimumDalamudVersion > Util.AssemblyVersionParsed)
throw new PluginPreconditionFailedException($"Unable to load {this.Name}, Dalamud version is lower than minimum required version {this.Manifest.MinimumDalamudVersion}");
this.State = PluginState.Loading;
Log.Information($"Loading {this.DllFile.Name}");

View file

@ -16,7 +16,7 @@ public interface IPluginManifest
/// Gets the public name of the plugin.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets a punchline of the plugins functions.
/// </summary>
@ -26,7 +26,7 @@ public interface IPluginManifest
/// Gets the author/s of the plugin.
/// </summary>
public string Author { get; }
/// <summary>
/// Gets a value indicating whether the plugin can be unloaded asynchronously.
/// </summary>
@ -41,17 +41,22 @@ public interface IPluginManifest
/// Gets the assembly version of the plugin's testing variant.
/// </summary>
public Version? TestingAssemblyVersion { get; }
/// <summary>
/// Gets the minimum Dalamud assembly version this plugin requires.
/// </summary>
public Version? MinimumDalamudVersion { get; }
/// <summary>
/// Gets the DIP17 channel name.
/// </summary>
public string? Dip17Channel { get; }
/// <summary>
/// Gets the last time this plugin was updated.
/// </summary>
public long LastUpdate { get; }
/// <summary>
/// Gets a changelog, null if none exists.
/// </summary>
@ -88,7 +93,7 @@ public interface IPluginManifest
/// Gets an URL to the website or source code of the plugin.
/// </summary>
public string? RepoUrl { get; }
/// <summary>
/// Gets a description of the plugins functions.
/// </summary>

View file

@ -75,6 +75,10 @@ internal record PluginManifest : IPluginManifest
[JsonConverter(typeof(GameVersionConverter))]
public GameVersion? ApplicableVersion { get; init; } = GameVersion.Any;
/// <inheritdoc/>
[JsonProperty]
public Version? MinimumDalamudVersion { get; init; }
/// <inheritdoc/>
[JsonProperty]
public int DalamudApiLevel { get; init; } = PluginManager.DalamudApiLevel;