👀Writing Your First Plugin

Writing a plugin may seem difficult, but it is pretty straightforward!

First Lines of Code

LabAPI implements a Module Pattern to load plugins. Because of this, plugins should have a main class that implements the Plugin abstract class.

MyFirstPlugin.cs
public class MyFirstPlugin : Plugin
{
    // The name of the plugin
    public override string Name { get; } = "My First Plugin";
    // The description of the plugin
    public override string Description { get; } = "This plugin does magic!";
    // The author of the plugin
    public override string Author { get; } = "Me!"
    // The current version of the plugin
    public override Version Version { get; } = new Version(1, 0, 0, 0);
    // The required version of LabAPI (usually the version the plugin was built with)
    public override Version RequiredApiVersion { get; } = new (LabApiProperties.CompiledVersion);
}

Entry point

You can override the Plugin::Enable() method to make your entry point:

Exit Point

You can override the Plugin::Disable() method to make your exit point:

Loading Priorities

In the case of a server with multiple plugins, your plugin may have to use an event before others because it has more importance or priority, for those cases you may override the Priority property.

It can also be useful for some plugins that serve as libraries for other plugins, such as custom permissions systems, etc.

Last updated

Was this helpful?