Aero LogoAero Docs

Plugins & Configuration

Learn how to build modular plugins for the Aero Framework, handle configurations automatically using YAML, and manage plugin loading lifecycles.

Creating a Plugin

Plugins in Aero are self-contained assembly libraries (compiled DLLs) loaded dynamically from the server resource's Plugins/ directory.

To start developing a plugin, reference Aero.API.dll in your C# class library and inherit from the base class Plugin<TConfig>.

Plugin Configuration (`IConfig`)

Aero features automated YAML configuration serialization. By defining a configuration model that implements IConfig, the framework automatically generates and loads a YAML config file named <PluginName>.yml inside the plugin directory.

Code Implementation

Here is a complete template showcasing a plugin implementation with its configuration file setup:

using System;
using Aero.API;
using Aero.API.Interfaces;

// 1. Define your configuration class
public class HelloPluginConfig : IConfig
{
    public bool Enabled { get; set; } = true;
    public string Message { get; set; } = "Welcome to the server!";
    public int MaxConnections { get; set; } = 100;
}

// 2. Inherit from Plugin<TConfig>
public class HelloPlugin : Plugin<HelloPluginConfig>
{
    public override string Name => "HelloPlugin";
    public override string Author => "Vertex Tools";
    public override string Description => "A demo plugin managing welcome configs.";
    public override Version Version => new Version(1, 0, 0);
    public override Version RequiredFramework => new Version(1, 0, 0);

    // This property is populated by the loader automatically
    public static HelloPluginConfig Config { get; set; }

    public override void OnLoad()
    {
        Log.Info($"[{Name}] loaded successfully!");
        if (Config.Enabled)
        {
            Log.Success($"Greeting: {Config.Message}");
        }
    }

    public override void OnUnload()
    {
        Log.Warn($"[{Name}] has been unloaded.");
    }
}

Lifecycle Pipeline

Aero handles assembly loading through the following sequential pipeline:

  1. Assembly Scanning: Checks the Plugins/ folder for `.dll` extensions.
  2. Framework Verification: Verifies that the plugin's RequiredFramework version matches or is compatible with the core engine version.
  3. Config Instantiation: Automatically loads/creates the config file and populates the static Config property.
  4. Bootstrap: Triggers the OnLoad() override.