Integrating Multiple Plugins
Introduction
AnchorChain provides a few methods to ensure that mods can both be dependent on each other and modify each other.
All dependencies in AnchorChain are hard dependencies, meaning that even an implication that another mod should exist will be taken to mean that it must. To make this as clear as possible, anything implying a dependency will be in the implicit dependencies section.
Explicit Dependencies
ACDependency
The ACDependency attribute is AnchorChain's way of adding explicit dependencies to a plugin. It also allows for version-specific dependencies with SemVer.
Arguments
string guid
The GUID of the dependency as specified in its
ACPlugin
attribute.string minVersion
The minimum version of the dependency, as specified in its
ACPlugin
attribute. If this is set to null, it will be assumed that there is no minimum version. This must be in a format acceptable bySystem.Version
.string maxVersion
The maximum version of the dependency, as specified in its
ACPlugin
attribute. If this is set to null, it will be assumed that there is no maximum version. This must be in a format acceptable bySystem.Version
.
To add other-plugin
as a versionless dependency to the NewPlugin class we created in Writing A Basic Plugin, we can add the line [ACDependency("<GUID of plugin>")]
as seen below.
Implicit Dependencies
ACPlugin Ordering Dependencies
ACPlugin
has two arguments (before
and after
) which create implicit dependencies. As mentioned in the introduction, all dependencies in AnchorChain are hard dependencies, so your plugin will not load without these implicit dependencies. These tags are discussed at more length in the ordering dependencies section.
Incompatibilities
ACIncompatibility
The ACIncompatibility attribute adds explicit incompatibilities to a plugin. It does not allow for version-specific incompatibility.
Arguments
string guid
The GUID of the incompatibility as specified in itsACPlugin
attribute.
To make our example plugin incompatible with the other-plugin
plugin, we can add the line [ACIncompatibility("io.github.other-creator.other-plugin")]
as shown below.
ACPlugin Ordering Incompatibilities
When plugin load order is resolved, AnchorChain screens for any "ordering loops" formed by two plugins that both want to load before or after the other. If AnchorChain detects an ordering loop, it will not load either plugin, as the ordering is understood as a hard dependency as discussed here.
Ordering Dependency Loading
ACPlugin Ordering
The ACPlugin attribute provides built-in plugin ordering for dependent plugins. For your convenience, the ACPlugin documentation is copied below. If you need a refresher on its purpose, look here.
Ordering Independent Plugins
Since ordering plugins creates implicit dependencies, we must use another method to order non-dependent plugins. In AnchorChain, it is best practice to create a plugin that depends on both and orders them as desired. Doing so introduces minimal overhead within the main plugins and allows for adding context-specific patches. The general structure of such a plugin would be as follows.