Enhanced PluginReferenceAttribute
Proposal
I propose refining the PluginReferenceAttribute
by extending its functionalities in the following ways:
1. Introducing Minimum Version Requirement:
2. Mandatory Plugin Requirement:
bool
argument in the attribute, determining whether the dependent plugin is mandatory for the parent plugin’s operation.True
: true
and the dependent plugin is either missing or its version doesn’t meet the requirements, the parent plugin should be disabled.False
: false
, the parent plugin can continue to operate, albeit with limited functionality. Additionally, a warning should indicate that certain features might not function correctly due to the absence of the dependent plugin.using System;
namespace Oxide.Plugins
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class PluginReferenceAttribute : Attribute
{
public string Name { get; }
public string MinimumVersion { get; }
public bool IsRequired { get; }
public PluginReferenceAttribute(string name, string minimumVersion = null, bool isRequired = false)
{
Name = name;
MinimumVersion = minimumVersion;
IsRequired = isRequired;
}
}
}
[PluginReference(“CopyPaste”, “1.2.3”, true)] // here “true” indicates that the plugin is required
[PluginReference(“ImageLibrary”, “2.0.1”)]
[PluginReference(“IQChat”, “1.0.0”, false)] // here “false” indicates that the plugin is not required
Plugin CopyPaste, ImageLibrary, IQChat;