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.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 |
|---|---|
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 |
The check id must exist in warden.yml under the module you are reporting into, otherwise the report
is discarded. So is any report about a player holding a bypass permission.
confidence is 0–100 and means how sure you are, not how bad it is.
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.