-
Notifications
You must be signed in to change notification settings - Fork 0
Plugins
Create a new Java project in an IDE like IntelliJ
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'
}IMPORTANT - Do not use both an annotation and JSON to define a plugin. Pick one and only use that.
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"
}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.
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
}
}Compile your plugin and put it into the plugins/ directory of your Gallium Minecraft server. The /plugins command should show your plugin.