PaperMC/patches/server/0432-Add-PlayerItemCooldownEvent.patch

28 lines
1.3 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
2021-06-11 14:02:28 +02:00
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
2024-10-25 14:55:49 +02:00
index 3a45a149ec4a28f25ea9e45803ecbb7392b63f86..2a80b8e962bf9d01e720b5967f0feac7d5dcaa28 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
+++ b/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
2024-10-23 17:13:43 +02:00
@@ -11,6 +11,16 @@ public class ServerItemCooldowns extends ItemCooldowns {
2021-06-11 14:02:28 +02:00
this.player = player;
}
+ // Paper start - Add PlayerItemCooldownEvent
2021-06-11 14:02:28 +02:00
+ @Override
2024-10-25 14:55:49 +02:00
+ public void addCooldown(ItemStack item, int duration) {
+ io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent(this.player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(item.getItem()), duration);
2021-06-11 14:02:28 +02:00
+ if (event.callEvent()) {
+ super.addCooldown(item, event.getCooldown());
+ }
+ }
+ // Paper end - Add PlayerItemCooldownEvent
2021-06-11 14:02:28 +02:00
+
@Override
2024-10-23 17:13:43 +02:00
protected void onCooldownStarted(ResourceLocation groupId, int duration) {
super.onCooldownStarted(groupId, duration);