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, which delegates straight toEntriesService.update/EntriesService.increment, wired throughUpdatePlayerEntryPacket/IncrementPlayerEntryPacket(the same paths as/leaderboard setand the built-in trackers). The packet carries thesortdeclared for that id in the localconfig.yml(DESCwhen the id is not declared there).master:MageHicAPI.services().register(LeaderboardService.class, this.entries)— backed byEntryService, whoseupdateandincrementcall the internalsave/incrementwith a null sort, so the ranking direction already known for that leaderboard id is reused and not overwritten. No round trip, since it's already on the master.
From another paper plugin:
update overwrites the score across every current period bucket; increment adds delta to it instead. Both are reachable through the shared service, so neither needs a compile dependency on AstralLeaderboards.
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, the plugin instance exposes the same writes plus the reads and cache controls the shared service does not carry:
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/LeaderboardService.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.