Creating an Addon
Assuming you have already created your empty project, you will be required to create a new directory
called libs
by right-clicking your main
folder and clicking New -> Directory
.
Cope and paste your IBoosters JAR file into that new folder.
Adding InsurgenceBoosters as a dependency
Add the below dependencies to your pom.xml file; replace {JAR-NAME}
with the name of your IBoosters JAR file. A reference to the Spigot API is also included.
<dependencies>
<dependency>
<groupId>org.insurgencedev</groupId>
<artifactId>IBoosters</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/libs/{JAR-NAME}</systemPath>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.2-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Setting up the main class
After creating your main class, it should extend InsurgenceBoostersAddon
and override the necessary methods. The class should also be annotated with @IboostersAddon
.
package com.insurgencedev.exampleaddon;
import org.insurgencedev.insurgenceboosters.api.addon.IBoostersAddon;
import org.insurgencedev.insurgenceboosters.api.addon.InsurgenceBoostersAddon;
@IBoostersAddon(name = "ExampleAddon", version = "1.0.0", author = "Insurgence Dev Team", description = "Example Addon")
public class ExampleAddon extends InsurgenceBoostersAddon {
@Override
public void onAddonStart() {
}
@Override
public void onAddonReloadablesStart() {
}
@Override
public void onAddonReload() {
}
@Override
public void onAddonStop() {
}
}
Creating a custom config
Make a fresh class. It should extend the AddonConfig
class and override the onLoad()
function. To load and generate your configuration file based on the file in your internal resource folder, make sure the loadAddonConfig()
method is used in the constructor.
package org.insurgencedev.exampleaddon;
import org.insurgencedev.insurgencesets.api.addon.AddonConfig;
public class CustomConfig extends AddonConfig {
public static String MYSTRING = null;
public CustomConfig() {
loadAddonConfig("config.yml", "config.yml");
}
@Override
protected void onLoad() {
MYSTRING = getString("Test");
}
}
No Comments