diff options
author | md_5 <git@md-5.net> | 2017-04-19 18:04:32 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2017-04-19 18:04:32 +1000 |
commit | be9ef980b9aa272acf298a337da8157c6a620e95 (patch) | |
tree | 912af53e1361cea82c76121c6ccaf7e28561a414 /src/main | |
parent | e04a1793ae35519baf1f9e1b94c812a6e6712d5a (diff) | |
download | craftbukkit-be9ef980b9aa272acf298a337da8157c6a620e95.tar craftbukkit-be9ef980b9aa272acf298a337da8157c6a620e95.tar.gz craftbukkit-be9ef980b9aa272acf298a337da8157c6a620e95.tar.lz craftbukkit-be9ef980b9aa272acf298a337da8157c6a620e95.tar.xz craftbukkit-be9ef980b9aa272acf298a337da8157c6a620e95.zip |
Implement cooldown API
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 0397756c..62aab50b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -26,6 +26,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryView; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftMerchant; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.inventory.EntityEquipment; import org.bukkit.permissions.PermissibleBase; import org.bukkit.permissions.Permission; @@ -416,4 +417,27 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public int getExpToLevel() { return getHandle().getExpToLevel(); } + + @Override + public boolean hasCooldown(Material material) { + Preconditions.checkArgument(material != null, "material"); + + return getHandle().di().a(CraftMagicNumbers.getItem(material)); // PAIL: getCooldownTracker + } + + @Override + public int getCooldown(Material material) { + Preconditions.checkArgument(material != null, "material"); + + ItemCooldown.Info cooldown = getHandle().di().a.get(CraftMagicNumbers.getItem(material)); + return (cooldown == null) ? 0 : Math.max(0, cooldown.b - getHandle().di().b); + } + + @Override + public void setCooldown(Material material, int ticks) { + Preconditions.checkArgument(material != null, "material"); + Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown"); + + getHandle().di().a(CraftMagicNumbers.getItem(material), ticks); + } } |