PlayerStatisticChangeEvent
PlayerStatisticChangeEvent is the most flexible integration point in the current API.
It fires before the new value is applied, so listeners can:
- Cancel the change completely
- Replace the final value
- Apply multipliers, caps, or special rules
Technical Overview
Section titled “Technical Overview”- Cancellable: Yes
- Extends:
PlayerEvent
Methods
Section titled “Methods”| Method | Return Type | Description |
|---|---|---|
getStat() | StatisticType<T> | The statistic being changed. |
getOldValue() | T | Previous stored value. |
getNewValue() | T | New value about to be stored. |
setNewValue(T) | void | Overrides the final value. |
isCancelled() | boolean | Whether the update is blocked. |
setCancelled(boolean) | void | Cancels or allows the update. |
Usage Example
Section titled “Usage Example”@EventHandlerpublic void onStatChange(PlayerStatisticChangeEvent<Integer> event) { if (event.getStat().getKey().equals("completions") && event.getPlayer().hasPermission("parkour.double-completions")) { event.setNewValue(event.getNewValue() + 1); }}