Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.

Plugins

Findlay Richardson edited this page Jun 26, 2023 · 8 revisions

Creating the project

Create a new Java project in an IDE like IntelliJ

Gradle configuration

repositories {
    mavenCentral()
    maven { url 'https://repo.zenoc.net/repository/' }
}

dependencies {
    implementation 'net.zenoc.gallium:gallium:1.1.0-beta.2'
    implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
    implementation 'org.apache.logging.log4j:log4j-api:2.19.0'
    implementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.19.0'
    implementation 'org.slf4j:slf4j-api:2.0.1'
}

The meat and potatoes

Defining a plugin

IMPORTANT - Do not use both an annotation and JSON to define a plugin. Pick one and only use that.

JSON

JSON can be used to define a plugin. It should be a plugin.json file in your resources. Consider the following template:

{
    "mainClass": "net.zenoc.gallium.test.Main",
    "name": "GalliumTestPlugin",
    "id": "testplugin",
    "description": "A plugin for testing thingies",
    "authors": ["SlimeDiamond"],
    "version": "1.1"
}

Annotation

Plugins can also be defined through an annotated main class. Consider the following template:

@Plugin(name = "Gallium",
        id = "gallium",
        description = "Gallium internal plugin",
        authors = { "SlimeDiamond" },
        version = "1.0")

If you are using this method, ensure that your Main-Class attribute is properly set.

Plugin main class

Once you have decided the method you are going to use to define your plugin, you need to create a main class. It should extend JavaPlugin. Consider the following example:

package net.zenoc.gallium.test;

import net.zenoc.gallium.api.annotations.PluginLifecycleListener;
import net.zenoc.gallium.plugin.PluginLifecycleState;
import net.zenoc.gallium.plugin.java.JavaPlugin;

public class GalliumPlugin extends JavaPlugin {
    @PluginLifecycleListener(PluginLifecycleState.ENABLED)
    public void onPluginEnable() {
        // Called when your plugin is enabled
    }

    @PluginLifecycleListener(PluginLifecycleState.DISABLED)
    public void onPluginDisable() {
        // Called when your plugin is disabled
    }
}

Plugin time!

Compile your plugin and put it into the plugins/ directory of your Gallium Minecraft server. The /plugins command should show your plugin.

Clone this wiki locally