Developer API
Punishments fires two cancellable events.
| Event | Fired when |
|---|---|
PlayerPunishedEvent |
A punishment is about to be saved |
PlayerPunishmentRevokedEvent |
A punishment is about to be revoked |
Both live in com.bradenkennedy.punishment.api.events and expose getPunishment(). Cancelling the event stops the action.
Example
Section titled “Example”import com.bradenkennedy.punishment.api.events.PlayerPunishedEvent;import com.bradenkennedy.punishment.api.model.PunishmentType;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;
public final class PunishmentLogger implements Listener {
@EventHandler public void onPunish(PlayerPunishedEvent event) { var punishment = event.getPunishment(); if (punishment.type() == PunishmentType.BAN && punishment.reason() == null) { event.setCancelled(true); } }}Punishment is a record in com.bradenkennedy.punishment.api.model.
| Field | Type | Notes |
|---|---|---|
id |
UUID |
Unique punishment ID |
target |
UUID |
The punished player |
type |
PunishmentType |
WARN, KICK, MUTE or BAN |
issuer |
PunishmentIssuer |
Issuer UUID and issuedAt instant |
reason |
String |
May be null |
expiry |
Instant |
null means permanent |
revocation |
Revocation |
null unless revoked |
expired() and revoked() are provided for convenience.