using Dalamud.Plugin.Internal.Types;
using Dalamud.Plugin.Internal.Types.Manifest;
namespace Dalamud.Plugin;
///
/// Interface representing an installed plugin, to be exposed to other plugins.
///
public interface IExposedPlugin
{
///
/// Gets the name of the plugin.
///
string Name { get; }
///
/// Gets the internal name of the plugin.
///
string InternalName { get; }
///
/// Gets a value indicating whether the plugin is loaded.
///
bool IsLoaded { get; }
///
/// Gets a value indicating whether this plugin's API level is out of date.
///
bool IsOutdated { get; }
///
/// Gets a value indicating whether the plugin is for testing use only.
///
bool IsTesting { get; }
///
/// Gets a value indicating whether this plugin is orphaned(belongs to a repo) or not.
///
bool IsOrphaned { get; }
///
/// Gets a value indicating whether this plugin is serviced(repo still exists, but plugin no longer does).
///
bool IsDecommissioned { get; }
///
/// Gets a value indicating whether this plugin has been banned.
///
bool IsBanned { get; }
///
/// Gets a value indicating whether this plugin is dev plugin.
///
bool IsDev { get; }
///
/// Gets a value indicating whether this manifest is associated with a plugin that was installed from a third party
/// repo.
///
bool IsThirdParty { get; }
///
/// Gets the plugin manifest.
///
ILocalPluginManifest Manifest { get; }
///
/// Gets the version of the plugin.
///
Version Version { get; }
///
/// Gets a value indicating whether the plugin has a main UI.
///
public bool HasMainUi { get; }
///
/// Gets a value indicating whether the plugin has a config UI.
///
public bool HasConfigUi { get; }
///
/// Opens the main UI of the plugin.
/// Throws if is false.
///
public void OpenMainUi();
///
/// Opens the config UI of the plugin.
/// Throws if is false.
///
public void OpenConfigUi();
}
///
/// Internal representation of an installed plugin, to be exposed to other plugins.
///
/// The plugin.
internal sealed class ExposedPlugin(LocalPlugin plugin) : IExposedPlugin
{
///
public string Name => plugin.Name;
///
public string InternalName => plugin.InternalName;
///
public bool IsLoaded => plugin.IsLoaded;
///
public Version Version => plugin.EffectiveVersion;
///
public bool HasMainUi => plugin.DalamudInterface?.LocalUiBuilder.HasMainUi ?? false;
///
public bool HasConfigUi => plugin.DalamudInterface?.LocalUiBuilder.HasConfigUi ?? false;
///
public bool IsOutdated => plugin.IsOutdated;
///
public bool IsTesting => plugin.IsTesting;
///
public bool IsOrphaned => plugin.IsOrphaned;
///
public bool IsDecommissioned => plugin.IsDecommissioned;
///
public bool IsBanned => plugin.IsBanned;
///
public bool IsDev => plugin.IsDev;
///
public bool IsThirdParty => plugin.IsThirdParty;
///
public ILocalPluginManifest Manifest => plugin.Manifest;
///
public void OpenMainUi()
{
if (plugin.DalamudInterface?.LocalUiBuilder.HasMainUi == true)
plugin.DalamudInterface.LocalUiBuilder.OpenMain();
else
throw new InvalidOperationException("Plugin does not have a main UI.");
}
///
public void OpenConfigUi()
{
if (plugin.DalamudInterface?.LocalUiBuilder.HasConfigUi == true)
plugin.DalamudInterface.LocalUiBuilder.OpenConfig();
else
throw new InvalidOperationException("Plugin does not have a config UI.");
}
}