Skip to content
AlphaHelix edited this page Aug 25, 2017 · 2 revisions

How to add addons?

To load your addons, you will have to put them inside the plugins/AlphaLibary/addons folder. This folder will only load addons and will not load spigot plugins! If not configured other way, the files of an addon will also be created inside this folder.

How to create addons?

The steps of creating an addon is similar to the steps of creating a spigot plugin. First you have to create a main class which should extend "Addon".

public class TestAddon extends Addon {

}

You can now easily acces the same methods as if it is a JavaPlugin.

After this creation, you will need to create a "addon.yml" where your plugin.yml is created in other cases. Inside this "addon.yml" you should specify a name, a author, a version, a description and a main class.

name: TestAddon
author: AlphaHelix
version: 1.0
description: Shows the way of create a Addon
main: de.alphahelix.testaddon.TestAddon

How to manage variables?

In the case you want Addon "A" to retrieve a variable from Addon "B". You can't use dependencies. You have to use the "CrossSystemManager".

In Addon "B" it should look like this:

CrossSystemManager.addVar(new CrossSystemVariable() {
    @Override
    public String value() {
        return JSONUtil.toJson("Some object you want to convert");
    }

    @Override
    public String name() {
        return "my var name";
    }
});

And in Addon "A" you can now retrieve the value like this:

if (CrossSystemManager.hasVar("my var name")) {
     String variableFromB = JSONUtil.getValue(CrossSystemManager.getVar("my var name"), String.class);
}

Clone this wiki locally