What goes in an addon
An addon is a JAR file with a foundry.yml file at its top level and a main class that implements FoundryAddon. In foundry.yml, the main field names the class Foundry starts. That class must have a constructor with no arguments.
yaml
id: example-addon
version: 1.0.0
main: me.example.ExampleAddon| Field | Meaning |
|---|---|
| id | Required. The addon's name used by Foundry. Use lowercase letters, numbers, underscores, or hyphens. |
| version | The addon's version. Foundry shows the version from the addon's code in its logs. |
| main | Required. The full name of the class Foundry starts. It must implement FoundryAddon and have a constructor with no arguments. |
Implement the addon
When Foundry starts the addon, it calls onEnable(api). Use the supplied FoundryAPI to register abilities and work with the server. The example addon uses a compileOnly dependency on Foundry, so it can use Foundry's code without bundling another copy of the plugin.
kotlin
class ExampleAddon : FoundryAddon {
override val id = "example-addon"
override val version = "1.0.0"
override fun onEnable(api: FoundryAPI) {
api.abilities.register(GreetingAbility())
}
override fun onDisable() {
// Release addon-owned resources here.
}
}kotlin
dependencies {
compileOnly(project(":"))
}Package and load
- Build the addon JAR with foundry.yml at the top level inside it.
- Copy the JAR into plugins/Foundry/packs.
- Restart the server. Foundry loads .jar files from this folder when it starts.
bash
./gradlew :FoundryExampleAddon:build