Skip to content

Plugin API

Sam Jakob Mearns edited this page Jun 10, 2019 · 1 revision

Plugin API

Fundamentals

  1. Your main class should extend VerdigrisPluginBase and should be annotated with @VerdigrisPlugin.
  2. Your main class must contain an #onEnable method that returns true. Even if the onEnable method itself is empty.
  3. You should do your best to make sure the package name of your plugin does not conflict with another. A safe bet is com.mydomain.myproject. If in doubt, just use io.github.<username>.myproject

Logging

Should you need to log information to the console, it's recommended that you use the PluginLogger. You can get your plugin's PluginLogger with #getLogger() in your plugin's main class.

Example

package com.samjakob.verdigris.test;

import com.cloutteam.jarcraftinator.plugin.api.VerdigrisPlugin;
import com.cloutteam.jarcraftinator.plugin.api.VerdigrisPluginBase;

@VerdigrisPlugin(
    name = "TestPlugin",
    version = "1.0.0",
    author = "SamJakob",
    description = "A test plugin for Verdigris."
)
public class TestPlugin extends VerdigrisPluginBase {

    @Override
    public boolean onEnable() {
        getLogger().log("Hello world!");
        return true;
    }

}

This is the log produced from that plugin running on Verdigris.

[2019-06-10 22:33:38] [INFO] Logger ready!
[2019-06-10 22:33:38] [INFO] Loading settings...
...
[2019-06-10 22:33:39] [INFO] [TestPlugin] Enabling TestPlugin v1.0.0 by SamJakob.
[2019-06-10 22:33:39] [INFO] [TestPlugin] Hello world!
[2019-06-10 22:33:39] [INFO] [TestPlugin] Enabled TestPlugin v1.0.0 by SamJakob.

Clone this wiki locally