diff options
Diffstat (limited to 'patches/api/0216-Add-PlayerItemCooldownEvent.patch')
-rw-r--r-- | patches/api/0216-Add-PlayerItemCooldownEvent.patch | 73 |
1 files changed, 62 insertions, 11 deletions
diff --git a/patches/api/0216-Add-PlayerItemCooldownEvent.patch b/patches/api/0216-Add-PlayerItemCooldownEvent.patch index 32321693b6..cf3a322855 100644 --- a/patches/api/0216-Add-PlayerItemCooldownEvent.patch +++ b/patches/api/0216-Add-PlayerItemCooldownEvent.patch @@ -6,14 +6,63 @@ Subject: [PATCH] Add PlayerItemCooldownEvent diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..07b3a93ea09f0ae7d0e7a5af3633a0c669d36fcf +index 0000000000000000000000000000000000000000..d072cdb992f23cbcf434317de1940204cf8d320d --- /dev/null +++ b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java -@@ -0,0 +1,79 @@ +@@ -0,0 +1,43 @@ +package io.papermc.paper.event.player; + -+import com.google.common.base.Preconditions; +import org.bukkit.Material; ++import org.bukkit.NamespacedKey; ++import org.bukkit.entity.Player; ++import org.bukkit.event.HandlerList; ++import org.jetbrains.annotations.ApiStatus; ++import org.jspecify.annotations.NullMarked; ++ ++/** ++ * Fired when a player receives an item cooldown when using an item. ++ * ++ * @see PlayerItemGroupCooldownEvent for a more general event when applied to a group of items ++ */ ++@NullMarked ++public class PlayerItemCooldownEvent extends PlayerItemGroupCooldownEvent { ++ ++ private final Material type; ++ ++ @ApiStatus.Internal ++ public PlayerItemCooldownEvent(final Player player, final Material type, final NamespacedKey cooldownGroup, final int cooldown) { ++ super(player, cooldownGroup, cooldown); ++ this.type = type; ++ } ++ ++ /** ++ * Get the material of the item affected by the cooldown. ++ * ++ * @return material affected by the cooldown ++ */ ++ public Material getType() { ++ return this.type; ++ } ++ ++ @Override ++ public HandlerList getHandlers() { ++ return PlayerItemCooldownEvent.getHandlerList(); ++ } ++ ++ public static HandlerList getHandlerList() { ++ return PlayerItemGroupCooldownEvent.getHandlerList(); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemGroupCooldownEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemGroupCooldownEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..e66aed33b165b86cc5e51eb5c29159232be4a9ef +--- /dev/null ++++ b/src/main/java/io/papermc/paper/event/player/PlayerItemGroupCooldownEvent.java +@@ -0,0 +1,81 @@ ++package io.papermc.paper.event.player; ++ ++import com.google.common.base.Preconditions; ++import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; @@ -23,31 +72,33 @@ index 0000000000000000000000000000000000000000..07b3a93ea09f0ae7d0e7a5af3633a0c6 + +/** + * Fired when a player receives an item cooldown. ++ * ++ * @see PlayerItemCooldownEvent for a more specific event when applied to a specific item. + */ +@NullMarked -+public class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable { ++public class PlayerItemGroupCooldownEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + -+ private final Material type; ++ private final NamespacedKey cooldownGroup; + private int cooldown; + + private boolean cancelled; + + @ApiStatus.Internal -+ public PlayerItemCooldownEvent(final Player player, final Material type, final int cooldown) { ++ public PlayerItemGroupCooldownEvent(final Player player, final NamespacedKey cooldownGroup, final int cooldown) { + super(player); -+ this.type = type; ++ this.cooldownGroup = cooldownGroup; + this.cooldown = cooldown; + } + + /** -+ * Get the material affected by the cooldown. ++ * Get the cooldown group as defined by an item's {@link org.bukkit.inventory.meta.components.UseCooldownComponent}. + * -+ * @return material affected by the cooldown ++ * @return cooldown group + */ -+ public Material getType() { -+ return this.type; ++ public NamespacedKey getCooldownGroup() { ++ return this.cooldownGroup; + } + + /** |