API
AfkPlusApi methods for balances, placement, boosts, and the pay-confirm switch.
Package me.st3ix.afkplus.api. Usernames are stored with the balance. Pass the current name, or null and AFKPlus uses the online name, then unknown.
Balance
| Method | Result |
|---|---|
long balance(UUID player) | Stored shards. 0 when the id is unknown or storage is down. |
boolean give(UUID player, String username, long amount) | Adds shards. false when amount is below 1. |
boolean take(UUID player, String username, long amount) | Removes up to the current balance. false when nothing can be removed. |
boolean set(UUID player, String username, long amount) | Replaces the balance. 0 is allowed. Negative is false. |
boolean pay(UUID from, String fromName, UUID to, String toName, long amount) | Moves shards. false for the same UUID, amount below 1, or too small a balance. No confirm screen and no chat. |
String currency() | Currency.Name. |
pay refunds the sender if the receiver's write fails.
Leaderboard
int place(UUID player) is the rank, starting at 1, ordered by balance descending and then username. 0 means the player has no row.
List<LeaderboardEntry> leaderboard(int limit) returns at most 100 entries, and an empty list when limit is below 1 or storage fails. LeaderboardEntry holds rank, uuid, username, and balance. AFKPlus does not draw this list.
Zone, boost, reward
| Method | Result |
|---|---|
boolean inZone(UUID player) | Whether that player is inside the AFK zone right now. |
PlayerBoost boost(UUID player) | Live secondsFactor and amountFactor, plus the stored end timestamps. Idle factors are 1. |
PlayerReward reward(UUID player) | AFK seconds and amount after boosts. null when the player is offline. |
Pay confirm
boolean payConfirm(UUID player) reads that player's entry in Shards.PayConfirmPlayers, then the Shards.PayConfirm default. boolean payConfirm(UUID player, boolean enabled) writes the UUID into Shards.PayConfirmPlayers and returns false if the file could not be saved. This only changes /shards pay for that player. It does not wrap pay(...).
Suggestions
Call place for one scoreboard line and leaderboard(10) when you need the whole top ten. Do not parse %afkplus_balance% from Java. Read Placeholders only for scoreboards and holograms. If a transfer should ask that player first, leave payConfirm(uuid) true and send them through /shards pay instead of pay.