Repository navigation
Addons
X-Warden loads addons from plugins/X-Warden/addons/. An addon is an ordinary jar with a few
manifest lines: X-Warden finds it on startup, hands it a data folder, a logger and the API, and shuts
it down cleanly when the server stops.
Addons are not plugins. They do not appear in /plugins, they do not need a plugin.yml, and they
cannot be enabled before X-Warden — which is the point, because they can then use the API from their
first line without guarding for its absence.
- Drop the jar into
plugins/X-Warden/addons/. - Restart, or run
/xwarden addons load <file>.jar. - Check it with
/xwarden addons.
/xwarden addons
Addons: 2
- Dashboard v1.0.0 by Drawethree | running
- Hello v1.0.0 by Drawethree | stopped
| Command | Does |
|---|---|
/xwarden addons |
lists what is loaded, and whether it is running |
/xwarden addons enable <name> |
starts one that is loaded but stopped |
/xwarden addons disable <name> |
stops one without unloading it |
/xwarden addons unload <name> |
stops it and lets go of its jar, so the file can be replaced |
/xwarden addons load <file>.jar |
loads a jar you have just dropped in, without a restart |
All five need xwarden.admin.
Disabling an addon does not release its jar. The addon stays loaded against the same classloader, so replacing the file and enabling it again runs the version it started with. Unload is what lets go:
/xwarden addons unload Dashboard
... replace the jar in plugins/X-Warden/addons/ ...
/xwarden addons load X-Warden-Dashboard-1.1.0.jar
Note that unload takes the addon's name and load takes the file name; they are rarely
the same word. Tab completion offers the right kind for each.
The dashboard's Addons page does the same thing without the typing: Unload on the row, replace the jar, then pick it from the list of jars in the folder that are not loaded. The panel cannot unload itself — that request would succeed and then have nothing left to answer with.
An addon that another loaded addon depends on will not unload — unload the dependent first. The console names it.
Replacing a jar while it is still loaded is safe in the sense that nothing is corrupted: X-Warden loads every addon from its own private copy, so the file on disk is never the one being read. It simply has no effect until the addon is unloaded and loaded again.
Each addon gets its own folder — plugins/X-Warden/addons/<Addon Name>/ — for its config and data.
Deleting the jar removes the addon; the folder stays, so its settings survive an upgrade.
X-Warden says why, by name, in the console. The usual reasons:
| It says | What happened |
|---|---|
| its manifest has no X-Warden-Addon-Class | the jar is not an addon, or was built without the manifest entries |
| needs 'X', which is not available | it declares a dependency on another addon you have not installed |
| is in a circular dependency | two addons each declare they need the other |
| does not implement XWardenAddon | the class named in the manifest is not an addon class |
| asks for X-Warden 1.2.0 and this is 1.0.0 | it was built for a newer X-Warden. It still tries to load |
| needs the Adventure library | the addon was built against Adventure and this server is Spigot. Run Paper, or ask the author to rebuild |
One broken addon never stops the others, and it never stops X-Warden. An addon that throws while starting is disabled on its own and everything else carries on.
The contract is in X-WardenAPI, which you compile
against at provided scope — the same artifact the Developer API page covers.
public final class MyAddon implements XWardenAddon {
@Override
public void onEnable(XWardenAddonContext context) {
XWardenAPI warden = context.getAPI();
context.getLogger().info("Watching " + warden.getModulesApi().moduleIds());
}
@Override
public void onDisable() {
// stop anything you started
}
}Your jar's manifest:
X-Warden-Addon-Class: com.example.MyAddon
X-Warden-Addon-Name: MyAddon
X-Warden-Addon-Version: 1.0.0
X-Warden-Addon-Author: You
X-Warden-Addon-Description: What it is for
X-Warden-Min-Version: 1.0.0
X-Warden-Priority: 50
X-Warden-Depends: SomeOtherAddon
Only X-Warden-Addon-Class is required. X-Warden-Depends is a comma-separated list of addon
names; anything it lists is guaranteed to have loaded and started first, and your addon is
skipped if one of them is not installed. X-Warden-Priority orders addons that do not depend on each
other — lower loads first, and 50 is the default.
With Maven, maven-jar-plugin writes those entries for you:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<X-Warden-Addon-Class>com.example.MyAddon</X-Warden-Addon-Class>
<X-Warden-Addon-Name>MyAddon</X-Warden-Addon-Name>
<X-Warden-Addon-Version>${project.version}</X-Warden-Addon-Version>
<X-Warden-Addon-Author>You</X-Warden-Addon-Author>
</manifestEntries>
</archive>
</configuration>
</plugin>getAPI() |
the full API, already published by the time onEnable runs |
getDataFolder() |
a folder of your own, created for you |
getLogger() |
a logger that says which addon a line came from |
registerEvents(listener) |
a Bukkit listener that is unregistered when you are disabled |
getPlugin() |
X-Warden itself, for the few APIs that insist on a Plugin
|
call(callable) / sync(runnable)
|
run something on the server thread and wait for it |
async(runnable) |
run something off it; cancelled when you are disabled |
call is what you need whenever you are working on a thread of your own — a web request, a socket, a
scheduled job — and have to touch the server to answer it. It never waits forever: on a shutting-down
server it throws WardenSyncException rather than parking your thread permanently.
Listeners and tasks registered through the context are released for you. Anything else you started
is yours to stop in onDisable — a thread, a socket, an HTTP server. X-Warden closes your
classloader once onDisable returns, and a thread still running against a closed classloader keeps
the whole addon alive and fails in ways nothing will explain. X-Warden names any it finds, so watch
the console after a reload.
onDisable is given a bounded amount of time. An addon that hangs there is reported and left behind
rather than being allowed to hang the server's shutdown.