feat: add "orphaned plugin" status when the plugin has no associated repo

This commit is contained in:
goat 2022-07-03 18:01:50 +02:00
parent ba5f3eae3b
commit 12722c776d
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
3 changed files with 17 additions and 4 deletions

View file

@ -209,6 +209,12 @@ internal class LocalPlugin : IDisposable
/// </summary>
public bool IsTesting => this.Manifest.IsTestingExclusive || this.Manifest.Testing;
/// <summary>
/// Gets a value indicating whether or not this plugin is orphaned(belongs to a repo) or not.
/// </summary>
public bool IsOrphaned => !this.IsDev && !this.Manifest.InstalledFromUrl.IsNullOrEmpty() &&
Service<PluginManager>.Get().Repos.All(x => x.PluginMasterUrl != this.Manifest.InstalledFromUrl);
/// <summary>
/// Gets a value indicating whether this plugin has been banned.
/// </summary>
@ -302,6 +308,9 @@ internal class LocalPlugin : IDisposable
if (this.Manifest.Disabled)
throw new InvalidPluginOperationException($"Unable to load {this.Name}, disabled");
if (this.IsOrphaned)
throw new InvalidPluginOperationException($"Plugin {this.Name} had no associated repo.");
this.State = PluginState.Loading;
Log.Information($"Loading {this.DllFile.Name}");

View file

@ -1,5 +1,6 @@
using System.IO;
using Dalamud.Utility;
using Newtonsoft.Json;
namespace Dalamud.Plugin.Internal.Types;
@ -33,7 +34,7 @@ internal record LocalPluginManifest : PluginManifest
/// Gets a value indicating whether this manifest is associated with a plugin that was installed from a third party
/// repo. Unless the manifest has been manually modified, this is determined by the InstalledFromUrl being null.
/// </summary>
public bool IsThirdParty => !string.IsNullOrEmpty(this.InstalledFromUrl);
public bool IsThirdParty => !this.InstalledFromUrl.IsNullOrEmpty() && this.InstalledFromUrl != PluginRepository.MainRepoUrl;
/// <summary>
/// Save a plugin manifest to file.

View file

@ -15,7 +15,10 @@ namespace Dalamud.Plugin.Internal.Types;
/// </summary>
internal class PluginRepository
{
private const string DalamudPluginsMasterUrl = "https://kamori.goats.dev/Plugin/PluginMaster";
/// <summary>
/// The URL of the official main repository.
/// </summary>
public const string MainRepoUrl = "https://kamori.goats.dev/Plugin/PluginMaster";
private static readonly ModuleLog Log = new("PLUGINR");
@ -38,14 +41,14 @@ internal class PluginRepository
public PluginRepository(string pluginMasterUrl, bool isEnabled)
{
this.PluginMasterUrl = pluginMasterUrl;
this.IsThirdParty = pluginMasterUrl != DalamudPluginsMasterUrl;
this.IsThirdParty = pluginMasterUrl != MainRepoUrl;
this.IsEnabled = isEnabled;
}
/// <summary>
/// Gets a new instance of the <see cref="PluginRepository"/> class for the main repo.
/// </summary>
public static PluginRepository MainRepo => new(DalamudPluginsMasterUrl, true);
public static PluginRepository MainRepo => new(MainRepoUrl, true);
/// <summary>
/// Gets the pluginmaster.json URL.