From f9e76a69246c5ce93898b11c4bf2fcd57b8ad50c Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 19 Apr 2017 17:41:34 +1000 Subject: [PATCH] Add API for manipulating item cooldowns. By: md_5 --- .../java/org/bukkit/entity/HumanEntity.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java index ede84ef954..4b540fe8d5 100644 --- a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java @@ -2,6 +2,7 @@ package org.bukkit.entity; import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.inventory.MainHand; import org.bukkit.inventory.Merchant; import org.bukkit.inventory.Inventory; @@ -174,6 +175,37 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, Permissible, Inv */ public void setItemOnCursor(ItemStack item); + /** + * Check whether a cooldown is active on the specified material. + * + * @param material the material to check + * @return if a cooldown is active on the material + */ + public boolean hasCooldown(Material material); + + /** + * Get the cooldown time in ticks remaining for the specified material. + * + * @param material the material to check + * @return the remaining cooldown time in ticks + */ + public int getCooldown(Material material); + + /** + * Set a cooldown on the specified material for a certain amount of ticks. + * ticks. 0 ticks will result in the removal of the cooldown. + *

+ * Cooldowns are used by the server for items such as ender pearls and + * shields to prevent them from being used repeatedly. + *

+ * Note that cooldowns will not by themselves stop an item from being used + * for attacking. + * + * @param material the material to set the cooldown for + * @param ticks the amount of ticks to set or 0 to remove + */ + public void setCooldown(Material material, int ticks); + /** * Returns whether this player is slumbering. *