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.
repositories {
maven { url "https://repo.erdbeerbaerlp.de/repository/maven-public/" }
}
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
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
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");
}
}
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";
}