Addons & Addon API

4commands
1permission
3files
4min read
Sheet 50 of 53 · Developers

FilesMyAddon.java · MyListener.java · addon.yml

FileMyAddon.javaFileMyListener.javaCommand/is admin featuresCommand/is admin addons reloadAddons are standalone jars dropped in plugins/IgniteSky/addons/. IgniteSky loads each one on startup, hands it a typed API, and disables it on shutdown or reload. Addons only see the API (ignitesky-api), never the internals, so an update to the plugin shouldn't break them.

Running a server and only installing addons? Skip to Installing an addon.

1. Depend on the API

Add ignitesky-api as a compileOnly dependency. It is provided at runtime by IgniteSky.

build.gradle
dependencies {
  compileOnly 'com.ignitedev:ignitesky-api:1.1.0'
  compileOnly 'io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT'
}

2. Write the addon

APIIgniteAddonExtend IgniteAddon. The base class gives you api(), data(), logger() and the full context() (the host plugin for listeners and tasks, your private data folder, and the descriptor).

MyAddon.java
package com.example.myaddon;
 
import com.ignitedev.ignitesky.api.addon.IgniteAddon;
import org.bukkit.Bukkit;
 
public final class MyAddon extends IgniteAddon {
 
  @Override
  public void onEnable() {
    logger().info("MyAddon starting");
 
    // Persistent, namespaced to this addon, survives restarts:
    int runs = Integer.parseInt(data().getOr("runs", "0")) + 1;
    data().set("runs", String.valueOf(runs));
 
    // A normal Bukkit listener. Register it through the context, never against getPlugin():
    // IgniteSky unregisters it when the addon unloads, so a reload cannot leave it running.
    context().registerListener(new MyListener(api()));
  }
 
  @Override
  public void onDisable() {
    logger().info("MyAddon stopping");
  }
}

APIIgniteSkyAPIA listener uses the public island events and IgniteSkyAPI directly, all typed:

MyListener.java
import com.ignitedev.ignitesky.api.IgniteSkyAPI;
import com.ignitedev.ignitesky.api.event.IslandCreateEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
 
public record MyListener(IgniteSkyAPI api) implements Listener {
 
  @EventHandler
  public void onCreate(IslandCreateEvent event) {
    // react to a new island via event.getIsland() / the api
  }
}

Events you can listen to

Config keycom.ignitedev.ignitesky.api.eventEvery event is in com.ignitedev.ignitesky.api.event, extends IslandEvent (so getIsland() is always there), and is a plain Bukkit event.

EventWhen
IslandCreateEventAfter a new island is created and registered
IslandDeleteEventBefore an island is deleted. Cancellable: cancelling keeps it
IslandDeletedEventOnce the island is really gone. Purge your own data here, never on the cancellable one
IslandResetEventAfter /is reset rebuilt the terrain; the island keeps its identity, members and bank
IslandOwnerChangeEventAfter the island changed hands
IslandMemberJoinEventAfter a player joined, by invite, trust or an admin
IslandMemberLeaveEventAfter a player stopped being a member: left, kicked or removed by staff
IslandRoleChangeEventAfter a member's role changed
IslandLevelChangeEventAfter the level crossed a whole level on a worth change. Fired async
IslandUpgradeEventAfter an upgrade tier changed: bought, granted or reset
IslandPrestigeEventAfter the island prestiged
IslandMissionCompleteEventAfter a mission completed (the reward is claimed separately)
IslandBankChangeEventAfter money moved in or out of the bank. Fired async

IslandBankChangeEvent and IslandLevelChangeEvent are fired async. The rest are fired on the global region: IslandDeleteEvent before the delete (so a cancel can still stop it), every other one after the change has landed. On Folia, hop to an entity or location scheduler before touching the world.

For drawing minions with your own models, see Extension Points.

The API object

Outside an addon, grab it from Bukkit with Bukkit.getServicesManager().load(IgniteSkyAPI.class). Lookups return a CompletableFuture. They're usually already complete, so the continuation runs on your current thread; don't treat them as a way off a region thread.

MethodWhat it does
getIslandOf(uuid)The island a player owns or belongs to
getIslandAt(location)The island at a position
getIsland(islandId)Look up by island id
createIsland(owner, mode)Create one, by IslandModeType or by id ("caveblock"). Fails if the player is at their island cap, already has a create running, or no world could be set up
deleteIsland(island)Delete one. Fails if a listener cancels it, the island lives on another server, or a reset is still running
getLoadedIslands()Every known island. Don't modify the collection
registerMode(mode) / getMode(type) / getModes()Register a mode implementation under its id, replacing the one its file set up; look one up; list them all. Register during enable, before islands load
isFeatureEnabled(id)Whether a feature or core system is switched on, by the id `/is admin features` lists. Unknown ids read as off

A server can switch any system off, so an addon built on top should ask before it leans on one, e.g. api.isFeatureEnabled("bank"). With a system off nothing throws: the stored values (level, worth, bank balance) still read back, they just stop changing, and that system's events stop firing because nothing causes them.

Island is read-only: id, owner, mode, name, description, center, home, members, level, worth, bank balance, locked and createdAt. Each IslandMember carries an IslandRole (id, display name, weight, permissions) and answers hasPermission(IslandPermission).

Modes

A mode is a modes/<id>.yml file (see Custom Modes), so most new modes need no code. IslandModeType used to be a closed enum; it is now a small class keyed by that id. SKYBLOCK, ONEBLOCK and CHUNKBLOCK are still there, instances are interned so == keeps working, and valueOf, name() and values() stay, so an addon built against the enum compiles as it is. A switch over the mode or an EnumMap keyed by it no longer compiles: use mode.id() or a HashMap.

IslandModeType cave = IslandModeType.of("caveblock");
api.createIsland(player.getUniqueId(), "caveblock");
 
for (IslandMode mode : api.getModes()) {
  getLogger().info(mode.getType().id() + " runs on " + mode.getBase().id());
}

getBase() is the engine a mode behaves like: skyblock, oneblock or chunkblock. Chunk locking and OneBlock phases follow it, so check the base, not getMode() == CHUNKBLOCK, or a custom mode on that engine slips past your check. registerMode can take a new id, but the file is still what gives a mode its worlds and its menu tile, and worlds are made at startup: ship modes/<id>.yml with your addon and restart once.

3. Ship addon.yml

Fileaddon.ymlPut addon.yml in the jar root:

addon.yml
name: MyAddon
main: com.example.myaddon.MyAddon
version: 1.0.0
description: Does something useful with islands.

name and main are required; a jar without them is skipped. The name becomes a folder and a file name, so it may only use letters, digits, _, . and -. version defaults to 1.0.

Installing an addon

    1. Drop the jar in

      Put the addon jar in plugins/IgniteSky/addons/.

    2. Load it

      Command/is admin addons reloadStart the server, or run /is admin addons reload to load it without a restart. That tears every addon down and loads them again from disk.

    3. Confirm it loaded

      Command/is admin addonsRun /is admin addons to list everything currently loaded, with name, version and description.

CommandWhat it does
/is admin addonsList loaded addons
/is admin addons reloadDisable and reload every addon from disk

Permissionignitesky.adminCommand/is admin reloadBoth need ignitesky.admin. A plain /is admin reload reloads configs and language, not addons.

What each addon gets

ResourceDetail
Its own classloaderIsolated from other addons
A private data folderaddons/<name>/
A persistent key-value storeaddons/data/<name>.json

For the worth and world SPIs (feeding island value from a shop, or hosting worlds in Slime format), see Extension Points.

Loading the index

Enter openUp Down moveEsc close