Developer API
Listen to claims, cancel them, and see streaks break from your own plugin.
On this page
AlphaRewards fires four standard Bukkit events. Any plugin can listen to them, cancel a claim before it happens, or react once it is done. All of them live in dev.alphastudio.alpharewards.api.events.
There is no Maven artifact. Add the AlphaRewards jar to your project as a
compileOnly dependency, and declare softdepend: [AlphaRewards] or depend: [AlphaRewards] in your own plugin.yml.Events
| Event | Cancellable | Fires |
|---|---|---|
AlphaRewardPreClaimEvent | Yes | After the claim is validated and before it is recorded. Cancel it to block the claim entirely. |
AlphaRewardClaimEvent | No | After a claim has succeeded: it is recorded in the player's data and the reward commands have run. The save to disk is queued right after the event. |
AlphaRewardStreakBreakEvent | No | Whenever a streak resets, on join or at claim time. The streak is already reset when it fires. |
AutoClaimEvent | No | After a successful auto-claim on join. It fires in addition to the claim event, not instead of it. |
What each event carries
| Event | Getters |
|---|---|
AlphaRewardPreClaimEvent | getPlayer(), getDay(), getMode() (DAILY or STREAK), isCancelled(), setCancelled(boolean) |
AlphaRewardClaimEvent | getPlayer(), getDay(), getMode() |
AlphaRewardStreakBreakEvent | getPlayer() |
AutoClaimEvent | getPlayer(), getDay() |
Example listener
This blocks claims in a world where rewards should not be collected, and logs every successful claim:
public final class RewardListener implements Listener {
@EventHandler
public void onPreClaim(AlphaRewardPreClaimEvent event) {
if (event.getPlayer().getWorld().getName().equals("minigames")) {
event.setCancelled(true);
}
}
@EventHandler
public void onClaim(AlphaRewardClaimEvent event) {
getLogger().info(event.getPlayer().getName()
+ " claimed day " + event.getDay() + " (" + event.getMode() + ")");
}
}
A cancelled claim ends silently, with no message to the player. If you cancel one, tell the player why yourself.
