From c228c9297917f9916c441d772a75adde6e735a7a Mon Sep 17 00:00:00 2001
From: Aireil <33433913+Aireil@users.noreply.github.com>
Date: Mon, 22 Apr 2024 21:52:00 +0200
Subject: [PATCH] fix: testing API level being ignored (#1472)
Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
---
.../PluginInstaller/PluginInstallerWindow.cs | 10 +++++++---
Dalamud/Plugin/Internal/PluginManager.cs | 15 ++++++++++++---
Dalamud/Plugin/Internal/Types/LocalPlugin.cs | 6 +++---
.../Internal/Types/Manifest/IPluginManifest.cs | 10 ++++++++--
.../Types/Manifest/LocalPluginManifest.cs | 5 +++++
Dalamud/Plugin/Internal/Types/PluginManifest.cs | 4 ++++
6 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
index 80f821033..5c897b8fb 100644
--- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
@@ -2099,7 +2099,8 @@ internal class PluginInstallerWindow : Window, IDisposable
var useTesting = pluginManager.UseTesting(manifest);
var wasSeen = this.WasPluginSeen(manifest.InternalName);
- var isOutdated = manifest.DalamudApiLevel < PluginManager.DalamudApiLevel;
+ var effectiveApiLevel = useTesting && manifest.TestingDalamudApiLevel != null ? manifest.TestingDalamudApiLevel.Value : manifest.DalamudApiLevel;
+ var isOutdated = effectiveApiLevel < PluginManager.DalamudApiLevel;
// Check for valid versions
if ((useTesting && manifest.TestingAssemblyVersion == null) || manifest.AssemblyVersion == null)
@@ -2421,7 +2422,8 @@ internal class PluginInstallerWindow : Window, IDisposable
var canFeedback = !isThirdParty &&
!plugin.IsDev &&
!plugin.IsOrphaned &&
- plugin.Manifest.DalamudApiLevel == PluginManager.DalamudApiLevel &&
+ (plugin.Manifest.DalamudApiLevel == PluginManager.DalamudApiLevel
+ || plugin.Manifest.TestingDalamudApiLevel == PluginManager.DalamudApiLevel) &&
acceptsFeedback &&
availablePluginUpdate == default;
@@ -3323,7 +3325,9 @@ internal class PluginInstallerWindow : Window, IDisposable
var searchString = this.searchText.ToLowerInvariant();
var matcher = new FuzzyMatcher(searchString, MatchMode.FuzzyParts);
var hasSearchString = !string.IsNullOrWhiteSpace(this.searchText);
- var oldApi = manifest.DalamudApiLevel < PluginManager.DalamudApiLevel;
+ var oldApi = (manifest.TestingDalamudApiLevel == null
+ || manifest.TestingDalamudApiLevel < PluginManager.DalamudApiLevel)
+ && manifest.DalamudApiLevel < PluginManager.DalamudApiLevel;
var installed = this.IsManifestInstalled(manifest).IsInstalled;
if (oldApi && !hasSearchString && !installed)
diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs
index 266c26b9b..594becf63 100644
--- a/Dalamud/Plugin/Internal/PluginManager.cs
+++ b/Dalamud/Plugin/Internal/PluginManager.cs
@@ -1178,7 +1178,8 @@ internal class PluginManager : IInternalDisposableService
}
// API level - we keep the API before this in the installer to show as "outdated"
- if (manifest.DalamudApiLevel < DalamudApiLevel - 1 && !this.LoadAllApiLevels)
+ var effectiveApiLevel = this.UseTesting(manifest) && manifest.TestingDalamudApiLevel != null ? manifest.TestingDalamudApiLevel.Value : manifest.DalamudApiLevel;
+ if (effectiveApiLevel < DalamudApiLevel - 1 && !this.LoadAllApiLevels)
{
Log.Verbose($"API Level: {manifest.InternalName} - {manifest.AssemblyVersion} - {manifest.TestingAssemblyVersion}");
return false;
@@ -1698,7 +1699,7 @@ internal class PluginManager : IInternalDisposableService
if (plugin == null)
throw new Exception("Plugin was null when adding to list");
-
+
lock (this.pluginListLock)
{
this.installedPluginsList.Add(plugin);
@@ -1728,7 +1729,15 @@ 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.DalamudApiLevel == DalamudApiLevel)
+ .Where(remoteManifest =>
+ {
+ var useTesting = this.UseTesting(remoteManifest);
+ var candidateApiLevel = useTesting && remoteManifest.TestingDalamudApiLevel != null
+ ? remoteManifest.TestingDalamudApiLevel.Value
+ : remoteManifest.DalamudApiLevel;
+
+ return candidateApiLevel == DalamudApiLevel;
+ })
.Select(remoteManifest =>
{
var useTesting = this.UseTesting(remoteManifest);
diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
index 9f60ddc97..bca02a927 100644
--- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
+++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
@@ -167,7 +167,7 @@ internal class LocalPlugin : IDisposable
///
/// Gets a value indicating whether this plugin's API level is out of date.
///
- public bool IsOutdated => this.manifest.DalamudApiLevel < PluginManager.DalamudApiLevel;
+ public bool IsOutdated => this.manifest.EffectiveApiLevel < PluginManager.DalamudApiLevel;
///
/// Gets a value indicating whether the plugin is for testing use only.
@@ -318,8 +318,8 @@ internal class LocalPlugin : IDisposable
if (this.manifest.ApplicableVersion < dalamud.StartInfo.GameVersion)
throw new PluginPreconditionFailedException($"Unable to load {this.Name}, game is newer than applicable version {this.manifest.ApplicableVersion}");
- if (this.manifest.DalamudApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels)
- throw new PluginPreconditionFailedException($"Unable to load {this.Name}, incompatible API level {this.manifest.DalamudApiLevel}");
+ if (this.manifest.EffectiveApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels)
+ throw new PluginPreconditionFailedException($"Unable to load {this.Name}, incompatible API level {this.manifest.EffectiveApiLevel}");
// We might want to throw here?
if (!this.IsWantedByAnyProfile)
diff --git a/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs b/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs
index 59b2ff34a..4b0951397 100644
--- a/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs
+++ b/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs
@@ -63,11 +63,17 @@ public interface IPluginManifest
public List? Tags { get; }
///
- /// Gets the API level of this plugin. For the current API level, please see
- /// for the currently used API level.
+ /// Gets the API level of this plugin.
+ /// For the current API level, please see for the currently used API level.
///
public int DalamudApiLevel { get; }
+ ///
+ /// Gets the API level of the plugin's testing variant.
+ /// For the current API level, please see for the currently used API level.
+ ///
+ public int? TestingDalamudApiLevel { get; }
+
///
/// Gets the number of downloads this plugin has.
///
diff --git a/Dalamud/Plugin/Internal/Types/Manifest/LocalPluginManifest.cs b/Dalamud/Plugin/Internal/Types/Manifest/LocalPluginManifest.cs
index 1a0ab8faa..31469a914 100644
--- a/Dalamud/Plugin/Internal/Types/Manifest/LocalPluginManifest.cs
+++ b/Dalamud/Plugin/Internal/Types/Manifest/LocalPluginManifest.cs
@@ -45,6 +45,11 @@ internal record LocalPluginManifest : PluginManifest, ILocalPluginManifest
///
public Version EffectiveVersion => this.Testing && this.TestingAssemblyVersion != null ? this.TestingAssemblyVersion : this.AssemblyVersion;
+ ///
+ /// Gets the effective API level of this plugin.
+ ///
+ public int EffectiveApiLevel => this.Testing && this.TestingDalamudApiLevel != null ? this.TestingDalamudApiLevel.Value : this.DalamudApiLevel;
+
///
/// Save a plugin manifest to file.
///
diff --git a/Dalamud/Plugin/Internal/Types/PluginManifest.cs b/Dalamud/Plugin/Internal/Types/PluginManifest.cs
index baaf37558..01951c8a6 100644
--- a/Dalamud/Plugin/Internal/Types/PluginManifest.cs
+++ b/Dalamud/Plugin/Internal/Types/PluginManifest.cs
@@ -79,6 +79,10 @@ internal record PluginManifest : IPluginManifest
[JsonProperty]
public int DalamudApiLevel { get; init; } = PluginManager.DalamudApiLevel;
+ ///
+ [JsonProperty]
+ public int? TestingDalamudApiLevel { get; init; }
+
///
[JsonProperty]
public long DownloadCount { get; init; }