allow loading dev plugins with the wrong API level, but add a validation error

This commit is contained in:
goat 2024-06-28 23:45:12 +02:00
parent d628be9536
commit 7283e634e9
4 changed files with 26 additions and 2 deletions

View file

@ -2779,7 +2779,7 @@ internal class PluginInstallerWindow : Window, IDisposable
var disabled = this.updateStatus == OperationStatus.InProgress || this.installStatus == OperationStatus.InProgress;
// Disable everything if the plugin is outdated
disabled = disabled || (plugin.IsOutdated && !pluginManager.LoadAllApiLevels) || plugin.IsBanned;
disabled = disabled || (plugin.IsOutdated && !pluginManager.LoadAllApiLevels && !plugin.IsDev) || plugin.IsBanned;
// Disable everything if the plugin is orphaned
// Control will immediately be disabled once the plugin is disabled

View file

@ -1638,6 +1638,13 @@ internal class PluginManager : IInternalDisposableService
loadPlugin = false;
}
// Never automatically load outdated dev plugins.
if (devPlugin.IsOutdated)
{
loadPlugin = false;
Log.Warning("DevPlugin {Name} is outdated, not loading automatically - update DalamudPackager or SDK!", plugin.Manifest.InternalName);
}
plugin = devPlugin;
}

View file

@ -93,6 +93,9 @@ internal static class PluginValidator
if (string.IsNullOrEmpty(plugin.Manifest.Author))
problems.Add(new NoAuthorProblem());
if (plugin.IsOutdated)
problems.Add(new WrongApiLevelProblem());
return problems;
}
@ -192,4 +195,17 @@ internal static class PluginValidator
/// <inheritdoc/>
public string GetLocalizedDescription() => "Your plugin does not have an author in its manifest.";
}
/// <summary>
/// Representing a problem where a plugin has an outdated API level.
/// </summary>
public class WrongApiLevelProblem : IValidationProblem
{
/// <inheritdoc/>
public ValidationSeverity Severity => ValidationSeverity.Fatal;
/// <inheritdoc/>
public string GetLocalizedDescription() => "Your plugin specifies an outdated API level. " +
"Please update it by updating DalamudPackager or Dalamud.NET.Sdk.";
}
}

View file

@ -319,7 +319,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.EffectiveApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels)
// We want to allow loading dev plugins with a lower API level than the current Dalamud API level, for ease of development
if (this.manifest.EffectiveApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels && !this.IsDev)
throw new PluginPreconditionFailedException($"Unable to load {this.Name}, incompatible API level {this.manifest.EffectiveApiLevel}");
// We might want to throw here?