PlayerEvent
The PlayerEvent class is an abstract base for all events involving a specific player.
It provides developers with a streamlined way to access both the standard Bukkit Player object and the internal Santa Says User instance.
Technical Overview
Section titled “Technical Overview”- Package:
io.greenmc.santasays.api.event.player - Parent Class:
SantaSaysEvent
Methods
Section titled “Methods”| Method | Return Type | Description |
|---|---|---|
getPlayer() | Player | Returns the standard Bukkit Player associated with the event. |
getUser() | User | Returns the plugin-specific User object, containing stats and game data. |
Known Subclasses
Section titled “Known Subclasses”These events inherit all methods from PlayerEvent:
PlayerJoinAttemptEvent: Fired when a player tries to join an arena.PlayerLeaveGameEvent: Fired when a player exits an active game.PlayerStatisticChangeEvent: Fired when a player’s persistent stats (wins, streaks, etc.) are modified.
Usage in Listeners
Section titled “Usage in Listeners”When listening to any subclass of PlayerEvent, you can immediately access the User object to check for statistics or plugin-specific data without manual lookups.
@EventHandlerpublic void onAnyPlayerEvent(PlayerJoinAttemptEvent event) { // Accessing Bukkit Player Player bukkitPlayer = event.getPlayer();
// Accessing Santa Says User User user = event.getUser();
// Example: Check a statistic from the base event int totalWins = user.getStatistic(Statistic.WIN);}