Developer API
Two Bukkit events other plugins can listen to, one when a player joins an event by scoring and one when an event ends.
EventPulse fires two plain Bukkit events in the cc.arrowtan.eventpulse.api.event package, so a quest, battle pass or stats plugin can follow events without a hook command on every placement in events.yml. Both are fired on the main thread and neither can be cancelled.
ContestJoinEvent
Fired the first time a player scores in a running event, once per player per event. A player who is ignored, for example in creative mode or holding the bypass permission, never scores and so never fires it. In a team event it fires once the point has been put on the player's island.
| Getter | What it returns |
|---|---|
Player getPlayer() | The player who scored |
String getContestId() | The event's key in events.yml, for example spider_eggs, not its display name |
String getContestType() | The event's type, for example MINING or BARREL_CLAIM |
ContestEndEvent
Fired once per event when it ends, whether it ran to its timer, ended early on a FIXED objective, was stopped by an admin, or ended because the server shut down. It fires after the ranking is final and after the payout has run or been skipped.
| Getter | What it returns |
|---|---|
String getContestId() | The event's key in events.yml |
String getContestType() | The event's type |
List<UUID> getRanking() | Players best first. In a team event the members of the best placed island come first, each island's members ordered by their own points, and a player who scored for two islands is listed once, on the better placed one |
Map<UUID, Double> getScores() | Each player's own points for the event |
boolean isRewarded() | true when the payout ran. false when nobody scored, fewer than event-defaults.min-participants took part, the event has no usable rewards, or it was stopped without rewards |
boolean isStoppedByAdmin() | true when the event was ended with the stop command, or replaced by a forced start |
Listening
import cc.arrowtan.eventpulse.api.event.ContestEndEvent;
import cc.arrowtan.eventpulse.api.event.ContestJoinEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public final class EventPulseListener implements Listener {
@EventHandler
public void onJoin(ContestJoinEvent event) {
// event.getPlayer(), event.getContestId(), event.getContestType()
}
@EventHandler
public void onEnd(ContestEndEvent event) {
if (!event.getRanking().isEmpty()) {
// event.getRanking().get(0) is the winner
}
}
}Add EventPulse to softdepend in your plugin.yml, compile against the EventPulse jar as a provided dependency, and only register the listener when the class cc.arrowtan.eventpulse.api.event.ContestEndEvent can be loaded. That way your plugin still runs on servers without EventPulse.