Skip to content

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

  • Cancellable: Yes
  • Extends: PlayerEvent

MethodReturn TypeDescription
getStat()StatisticType<T>The statistic being changed.
getOldValue()TPrevious stored value.
getNewValue()TNew value about to be stored.
setNewValue(T)voidOverrides the final value.
isCancelled()booleanWhether the update is blocked.
setCancelled(boolean)voidCancels or allows the update.

@EventHandler
public void onStatChange(PlayerStatisticChangeEvent<Integer> event) {
if (event.getStat().getKey().equals("completions")
&& event.getPlayer().hasPermission("parkour.double-completions")) {
event.setNewValue(event.getNewValue() + 1);
}
}