Table of Contents

Creating Addons

Discord Integration addons are meant to be usable independant of the target minecraft loader. They are made to create custom slash commands or add other discord-side features without depending on any minecraft resources or mods.

Gradle Setup

  1. Add my maven repository
repositories {
    maven { url "https://repo.erdbeerbaerlp.de/repository/maven-public/" }
}
  1. Add dependency of DiscordIntegration-Core
dependencies {
    compileOnly 'de.erdbeerbaerlp:dcintegration.common:3.0.7'
    compileOnly group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'
}

Adding log4j is optional, but required if you want to use it for logging

Metadata setup

For your addon to be actually loaded, it needs some metadata in form of a .toml file inside of src/main/resources folder. It has to be named DiscordIntegrationAddon.toml. Full file path would be src/main/resources/DiscordIntegrationAddon.toml

Here is an documented example of such an toml file:

# Name of the addon
name = "Example Addon"

# Version of the addon
version = "1.0.0"
# Path to the main class of the addon
# Example: "com.example.exampleaddon.ExampleAddon"
#
# If this parameter is missing, your addon will not load
classPath = "com.example.exampleaddon.ExampleAddon"

# Author of the Addon (optional)
author = "ErdbeerbaerLP"

# Description of the Addon (optional)
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras efficitur tellus semper, elementum magna ac, tincidunt risus."

# Required parameter to specify if the addon is compatible with this API version
APIVersion = 3

Addon class file

Your addon class needs to implement DiscordIntegrationAddon.

Here a working example of a addon main class

public class ExampleAddon implements DiscordIntegrationAddon {

    @Override
    public void load(DiscordIntegration dc) {
        DiscordIntegration.LOGGER.info("Example Addon loaded");
    }

    @Override
    public void reload() {
        DiscordIntegration.LOGGER.info("Example Addon reloaded");
    }

    @Override
    public void unload(DiscordIntegration dc) {
        DiscordIntegration.LOGGER.info("Example Addon unloaded");
    }

}

Using Addon config files

To use a configuration file for your addon, you will have to register it in your load method. It is also recommended to reload that config in the reload method.

Here a working example of an addon class with config loading implemented

public class ExampleAddon implements DiscordIntegrationAddon {
    private ExampleConfig cfg;

    @Override
    public void load(DiscordIntegration dc) {
        DiscordIntegration.LOGGER.info("Example Addon loaded");
        cfg = AddonConfigRegistry.loadConfig(ExampleConfig.class, this);
        DiscordIntegration.LOGGER.info(cfg.exampleMessage);
    }

    @Override
    public void reload() {
        DiscordIntegration.LOGGER.info("Example Addon reloaded");
        cfg = AddonConfigRegistry.loadConfig(cfg,this);
    }

    @Override
    public void unload(Discord dc) {
        DiscordIntegration.LOGGER.info("Example Addon unloaded");
    }
}

… and the config class file:

public class ExampleConfig {
    @TomlComment({"Config entry comment", "You can also have multiple lines here"})
    public String exampleMessage = "Hello World";
}