Fix stats event call

This commit is contained in:
Nassim Jahnke 2024-12-17 22:19:33 +01:00
parent 972266605e
commit c55ad7092c
No known key found for this signature in database
GPG key ID: EF6771C01F6EF02F

View file

@ -1,15 +1,15 @@
--- a/net/minecraft/stats/StatsCounter.java
+++ b/net/minecraft/stats/StatsCounter.java
@@ -18,6 +_,12 @@
}
@@ -14,6 +_,12 @@
public void setValue(Player player, Stat<?> stat, int value) {
public void increment(Player player, Stat<?> stat, int amount) {
int i = (int)Math.min((long)this.getValue(stat) + amount, 2147483647L);
+ // CraftBukkit start - fire Statistic events
+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(player, stat, this.getValue(stat), value);
+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(player, stat, this.getValue(stat), i);
+ if (cancellable != null && cancellable.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.stats.put(stat, value);
this.setValue(player, stat, i);
}