PaperMC/patches/server-remapped/Add-PlayerItemCooldownEvent.patch
MiniDigger | Martin 95d25d98e8 Move patches around
2021-06-11 14:02:28 +02:00

39 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
Date: Tue, 25 Aug 2020 13:48:33 +0200
Subject: [PATCH] Add PlayerItemCooldownEvent
diff --git a/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java b/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
+++ b/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
@@ -0,0 +0,0 @@
package net.minecraft.world.item;
+import io.papermc.paper.event.player.PlayerItemCooldownEvent; // Paper
import net.minecraft.network.protocol.game.ClientboundCooldownPacket;
import net.minecraft.server.level.ServerPlayer;
public class ServerItemCooldowns extends ItemCooldowns {
- private final ServerPlayer player;
+ private final ServerPlayer player; public ServerPlayer getEntityPlayer() { return player; } // Paper - OBFHELPER
public ServerItemCooldowns(ServerPlayer player) {
this.player = player;
}
+ // Paper start
+ @Override
+ public void addCooldown(Item item, int duration) {
+ PlayerItemCooldownEvent event = new PlayerItemCooldownEvent(getEntityPlayer().getBukkitEntity(), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), duration);
+ if (event.callEvent()) {
+ super.addCooldown(item, event.getCooldown());
+ }
+ }
+ // Paper end
+
@Override
protected void onCooldownStarted(Item item, int duration) {
super.onCooldownStarted(item, duration);