Repository navigation
Developer API
XWardenAPI lets your plugin report into the same pipeline and read back what X-Warden knows.
Compile against X-Warden at provided scope and guard for its absence — most servers will not have
it installed:
XWardenAPI.find().ifPresent(warden -> {
warden.registerCheck("economy", "mygame-impossible-win"); // once, on enable
warden.report(player.getUniqueId(), "economy", "mygame-impossible-win", 80,
Map.of("Wagered", "1000", "Returned", "9999999"));
});find() returns empty when X-Warden is missing, disabled or still starting. getInstance() throws
instead, if you would rather fail loudly.
Guard the class, not just the call. A field or parameter typed as an X-Warden class is resolved when your own class links, which is before any
find()runs. Keep everything that names an X-Warden type in one package and enter it only after checking the plugin is installed. X-Prison Player Vaults is the worked example.
| Method | For |
|---|---|
registerCheck(moduleId, checkId) |
telling Warden a check id of yours exists |
report(player, moduleId, checkId, confidence, evidence) |
something you detected about a player |
reportBug(source, detail) |
a defect — reaches staff as a bug notice, never touches a violation level |
Register your check ids first. Warden resolves a check id against a fixed list, so anything it
does not recognise is treated as switched off and the report is discarded. Call registerCheck once
on enable, before your first report. It returns false if the module id is not one of Warden's own
— economy, integrity, automation or network.
A registered check picks up whatever the owner has written under
modules.<module>.checks.<check> in warden.yml, and Warden's ordinary defaults where they have
written nothing: enabled, on ALERT. An addon therefore cannot ship a check that punishes on its
own — only the server owner can raise it. Registrations survive /xwarden reload.
Keep your ids lowercase and hyphenated, and distinctive enough not to collide with another addon's.
A report is also discarded when the player holds a bypass permission, or when another plugin cancels
WardenViolationEvent.
confidence is 0–100 and means how sure you are, not how bad it is.
Warden fires two Bukkit events, so you do not have to poll.
| Event | When | Cancellable |
|---|---|---|
WardenViolationEvent |
a check has decided to report somebody, before anything is stored or acted on | yes |
WardenFlagResolvedEvent |
a staff member marked one finding as handled | no |
Cancelling WardenViolationEvent discards the finding entirely — no row in the flag list, no
violation level, no action. It is the same outcome as a bypass permission, and it is what to use when
your plugin knows something Warden cannot: an event world, a staff build session, a player your own
systems have already cleared.
@EventHandler
public void onWardenFlag(WardenViolationEvent event) {
if (myEventWorld.contains(event.getPlayer())) {
event.setCancelled(true);
}
}
⚠️ Both are often fired off the main thread. Analysis runs asynchronously and resolving writes to the database, so a handler must not touch the Bukkit API without hopping back to the server thread.isAsynchronous()tells you which you are on.
int score = warden.getAutomationScore(uuid);
Optional<AutomationBreakdown> breakdown = warden.getAutomationBreakdown(uuid);
int level = warden.getViolationLevel(uuid, "automation");
List<Violation> recent = warden.getRecentViolations(uuid, 10);
boolean trusted = warden.isTrusted(uuid, "integrity");If your plugin stores items on a player's behalf, register a ContainerSource. Without one, an
item hidden in your storage can never be reported as a duplicate — which makes it the best hiding
place on the server.
warden.registerContainerSource(new ContainerSource() {
public String id() { return "MyVaults"; }
public List<HeldItem> snapshot() { return List.copyOf(alreadyPrepared); }
});snapshot() is called asynchronously, so it must return an already-materialised list and must
not touch Bukkit state. Build that list beforehand, on the server thread, with describeStored:
warden.describeStored(item, ownerId, ownerName, "vault " + number, slot)
.ifPresent(alreadyPrepared::add);Work the identity out yourself and you will get it wrong: a prison pickaxe carries an identity of its own, everything else carries X-Warden's, and which is which depends on what is installed.
X-Warden is usually enabled after other plugins and addons, so registering during your own
onEnable will find nothing. Wait for PluginEnableEvent for X-Warden instead — that also covers
somebody installing it later without a restart.
warden.recordTransaction(uuid, "tokens", amount, "MyCasino", correlationId);
Optional<MultiplierBreakdown> chain = warden.auditMultipliers(player, "tokens");Use recordTransaction for money your own plugin moves outside the core currency API, so it appears
in reports and can be rolled back. Pass the same correlationId for both halves of a transfer.