PaperMC/Spigot-Server-Patches/0606-Add-PlayerItemCooldownEvent.patch
Riley Park 4e958e229f
We're going on an Adventure! (#4842)
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: zml <zml@stellardrift.ca>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
2021-02-21 20:45:33 +01:00

37 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: KennyTV <jahnke.nassim@gmail.com>
Date: Tue, 25 Aug 2020 13:48:33 +0200
Subject: [PATCH] Add PlayerItemCooldownEvent
diff --git a/src/main/java/net/minecraft/server/ItemCooldownPlayer.java b/src/main/java/net/minecraft/server/ItemCooldownPlayer.java
index 27cde8c15576efab9a60b5741c1cd54ed4b04c6c..9da02cf0a9a1b396c2ff0f79fdd2e95003399817 100644
--- a/src/main/java/net/minecraft/server/ItemCooldownPlayer.java
+++ b/src/main/java/net/minecraft/server/ItemCooldownPlayer.java
@@ -1,13 +1,25 @@
package net.minecraft.server;
+import io.papermc.paper.event.player.PlayerItemCooldownEvent; // Paper
+
public class ItemCooldownPlayer extends ItemCooldown {
- private final EntityPlayer a;
+ private final EntityPlayer a; public EntityPlayer getEntityPlayer() { return a; } // Paper - OBFHELPER
public ItemCooldownPlayer(EntityPlayer entityplayer) {
this.a = entityplayer;
}
+ // Paper start
+ @Override
+ public void setCooldown(Item item, int ticks) {
+ PlayerItemCooldownEvent event = new PlayerItemCooldownEvent(getEntityPlayer().getBukkitEntity(), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), ticks);
+ if (event.callEvent()) {
+ super.setCooldown(item, event.getCooldown());
+ }
+ }
+ // Paper end
+
@Override
protected void b(Item item, int i) {
super.b(item, i);