Add SpecialPluginSource to public API (#1357)

This commit is contained in:
KazWolfe 2023-09-07 10:33:46 -07:00 committed by GitHub
parent 37cb1f5dd0
commit 1dbf93e428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 17 deletions

View file

@ -56,7 +56,7 @@ public sealed class DalamudPluginInterface : IDisposable
this.configs = Service<PluginManager>.Get().PluginConfigs; this.configs = Service<PluginManager>.Get().PluginConfigs;
this.Reason = reason; this.Reason = reason;
this.SourceRepository = this.IsDev ? LocalPluginManifest.FlagDevPlugin : plugin.Manifest.InstalledFromUrl; this.SourceRepository = this.IsDev ? SpecialPluginSource.DevPlugin : plugin.Manifest.InstalledFromUrl;
this.IsTesting = plugin.IsTesting; this.IsTesting = plugin.IsTesting;
this.LoadTime = DateTime.Now; this.LoadTime = DateTime.Now;
@ -118,8 +118,8 @@ public sealed class DalamudPluginInterface : IDisposable
/// Gets the repository from which this plugin was installed. /// Gets the repository from which this plugin was installed.
/// ///
/// If a plugin was installed from the official/main repository, this will return the value of /// If a plugin was installed from the official/main repository, this will return the value of
/// <see cref="LocalPluginManifest.FlagMainRepo"/>. Developer plugins will return the value of /// <see cref="SpecialPluginSource.MainRepo"/>. Developer plugins will return the value of
/// <see cref="LocalPluginManifest.FlagDevPlugin"/>. /// <see cref="SpecialPluginSource.DevPlugin"/>.
/// </summary> /// </summary>
public string SourceRepository { get; } public string SourceRepository { get; }

View file

@ -873,7 +873,7 @@ internal partial class PluginManager : IDisposable, IServiceType
} }
// Document the url the plugin was installed from // Document the url the plugin was installed from
manifest.InstalledFromUrl = repoManifest.SourceRepo.IsThirdParty ? repoManifest.SourceRepo.PluginMasterUrl : LocalPluginManifest.FlagMainRepo; manifest.InstalledFromUrl = repoManifest.SourceRepo.IsThirdParty ? repoManifest.SourceRepo.PluginMasterUrl : SpecialPluginSource.MainRepo;
manifest.Save(manifestFile, "installation"); manifest.Save(manifestFile, "installation");

View file

@ -13,18 +13,6 @@ namespace Dalamud.Plugin.Internal.Types.Manifest;
/// </summary> /// </summary>
internal record LocalPluginManifest : PluginManifest, ILocalPluginManifest internal record LocalPluginManifest : PluginManifest, ILocalPluginManifest
{ {
/// <summary>
/// Flag indicating that a plugin was installed from the official repo.
/// </summary>
[JsonIgnore]
public const string FlagMainRepo = "OFFICIAL";
/// <summary>
/// Flag indicating that a plugin is a dev plugin..
/// </summary>
[JsonIgnore]
public const string FlagDevPlugin = "DEVPLUGIN";
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the plugin is disabled and should not be loaded. /// Gets or sets a value indicating whether the plugin is disabled and should not be loaded.
/// This value supersedes the ".disabled" file functionality and should not be included in the plugin master. /// This value supersedes the ".disabled" file functionality and should not be included in the plugin master.
@ -51,7 +39,7 @@ internal record LocalPluginManifest : PluginManifest, ILocalPluginManifest
/// Gets a value indicating whether this manifest is associated with a plugin that was installed from a third party /// 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. /// repo. Unless the manifest has been manually modified, this is determined by the InstalledFromUrl being null.
/// </summary> /// </summary>
public bool IsThirdParty => !this.InstalledFromUrl.IsNullOrEmpty() && this.InstalledFromUrl != FlagMainRepo; public bool IsThirdParty => !this.InstalledFromUrl.IsNullOrEmpty() && this.InstalledFromUrl != SpecialPluginSource.MainRepo;
/// <summary> /// <summary>
/// Gets the effective version of this plugin. /// Gets the effective version of this plugin.

View file

@ -0,0 +1,17 @@
namespace Dalamud.Plugin.Internal.Types.Manifest;
/// <summary>
/// A fake enum representing "special" sources for plugins.
/// </summary>
public static class SpecialPluginSource
{
/// <summary>
/// Indication that this plugin came from the official Dalamud repository.
/// </summary>
public const string MainRepo = "OFFICIAL";
/// <summary>
/// Indication that this plugin is loaded as a dev plugin. See also <see cref="DalamudPluginInterface.IsDev"/>.
/// </summary>
public const string DevPlugin = "DEVPLUGIN";
}