PlayerStatisticChangeEvent
PlayerStatisticChangeEvent<T> exposes the statistic key, previous value, and mutable new value before a KOTL user update is written.
Technical Overview
Section titled “Technical Overview”- Package:
dev.despical.kotl.api.events.player - Parent Class:
PlayerEvent - Cancellable: Yes
Methods
Section titled “Methods”| Method | Return Type | Description |
|---|---|---|
getStat() | StatisticType<T> | Statistic being updated. |
getOldValue() | T | Value before the requested update. |
getNewValue() | T | Value that will be stored. |
setNewValue(T) | void | Replaces the pending value. |
isCancelled() | boolean | Whether the update is blocked. |
setCancelled(boolean) | void | Blocks or restores the update. |
Integer Statistics
Section titled “Integer Statistics”Statistics.KILLStatistics.DEATHStatistics.SCOREStatistics.TOURS_PLAYED
Statistics.ARENA_SCORES uses Map<String, Integer>.
Score Booster Example
Section titled “Score Booster Example”import dev.despical.kotl.api.events.player.PlayerStatisticChangeEvent;import dev.despical.kotl.stats.Statistics;import org.bukkit.event.EventHandler;
@EventHandlerpublic 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.