Skip to content

PlayerStatisticChangeEvent

PlayerStatisticChangeEvent<T> exposes the statistic key, previous value, and mutable new value before a KOTL user update is written.


  • Package: dev.despical.kotl.api.events.player
  • Parent Class: PlayerEvent
  • Cancellable: Yes

MethodReturn TypeDescription
getStat()StatisticType<T>Statistic being updated.
getOldValue()TValue before the requested update.
getNewValue()TValue that will be stored.
setNewValue(T)voidReplaces the pending value.
isCancelled()booleanWhether the update is blocked.
setCancelled(boolean)voidBlocks or restores the update.

  • Statistics.KILL
  • Statistics.DEATH
  • Statistics.SCORE
  • Statistics.TOURS_PLAYED

Statistics.ARENA_SCORES uses Map<String, Integer>.


import dev.despical.kotl.api.events.player.PlayerStatisticChangeEvent;
import dev.despical.kotl.stats.Statistics;
import org.bukkit.event.EventHandler;
@EventHandler
public void onStatisticChange(PlayerStatisticChangeEvent<Integer> event) {
if (event.getStat() != Statistics.SCORE || !event.getPlayer().hasPermission("kotl.double-score")) {
return;
}
int gain = event.getNewValue() - event.getOldValue();
event.setNewValue(event.getOldValue() + gain * 2);
}

Cancelling the event leaves the old value unchanged.