Developer API
AstralLeaderboards exposes writes to other plugins through a single shared-service interface registered in AstralCore's service registry — integrating plugins do not need a compile dependency on AstralLeaderboards itself.
LeaderboardService
Registered by both modules on onEnable:
paper:AstralPaperAPI.registerService(LeaderboardService.class, this.leaderboards)— backed byLeaderboardServiceImpl, whoseupdatedelegates toEntriesService.update(an overwrite, wired throughUpdatePlayerEntryPacket, same as/leaderboard set).master:MageHicAPI.services().register(LeaderboardService.class, this.entries)— backed byEntryService, whoseupdatereuses the ranking direction already known for that leaderboard id (sortFor(leaderboardId)) and callssavedirectly (no round trip, since it's already on the master).
From another paper plugin:
update always overwrites the score across every current period bucket — there is no shared-service increment. To add a delta instead of setting an absolute value, a plugin must depend on AstralLeaderboards directly and call AstralLeaderboards.get().entries().increment(...) (see below); the built-in trackers use this path.
Known consumers in the codebase: AstralEconomy (TransactionService) and AstralJobs (LeaderboardListener, pushes a job's level on level-up).
Direct plugin API (paper)
For code that already depends on the AstralLeaderboards artifact:
Getter | Type | Use |
|---|---|---|
|
| Declared leaderboards, |
|
| Per-player standings: |
|
| Per-leaderboard top-N reads: |
|
| In-memory per-session accumulators for the built-in trackers (see below). |
|
| The |
Built-in trackers
PlayerDataListener accumulates three stats per online player in memory (PlayerData, a Map<BuiltinLeaderboard, Integer>) and flushes them to the network as a single increment call per stat on PlayerQuitEvent — not on every event, to avoid a network round trip per block break:
| Bukkit event | Counts | Bypass check |
|---|---|---|---|
|
| +1 per block broken. |
|
|
| +1 per kill, only when |
|
|
| +1 only when |
|
On quit, each accumulated stat is flushed only if builtin-leaderboards in config.yml maps that BuiltinLeaderboard to a leaderboard id; otherwise it is dropped (logged as a skip, not an error). If the player disconnects without a PlayerQuitEvent firing normally (e.g. server crash), the in-memory accumulator for that session is lost — the built-in trackers are best-effort, not durable.
BuiltinLeaderboard
Fixed set — adding a new automatically-tracked stat requires a code change (a new enum value, a new listener method, and a builtin-leaderboards entry), there is no registration hook.
Extending: custom leaderboards
No code is required to add a new leaderboard — declare a new entry under leaderboards in config.yml (see Configuration) and start writing to it via LeaderboardService.update or, from within the plugin, plugin.entries().increment(...). The master learns the leaderboard's sort direction from the first write packet it receives and persists it, so no master-side configuration is needed either.