aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0202-ItemStack-getMaxItemUseDuration.patch
blob: 285c3b0db72d531c792a9cac7abd7002aa49c6e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 5 Jun 2018 23:00:29 -0400
Subject: [PATCH] ItemStack#getMaxItemUseDuration

Allows you to determine how long it takes to use a usable/consumable item

diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index c9093275d2b78b6e2f59e64efab0b4775ff0b43b..ca75f84d2beeef0636fc7032297bf038d13d97e0 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -173,6 +173,13 @@ public final class CraftItemStack extends ItemStack {
         return (this.handle == null) ? Material.AIR.getMaxStackSize() : this.handle.getItem().getMaxStackSize();
     }
 
+    // Paper start
+    @Override
+    public int getMaxItemUseDuration() {
+        return handle == null ? 0 : handle.getUseDuration();
+    }
+    // Paper end
+
     @Override
     public void addUnsafeEnchantment(Enchantment ench, int level) {
         Validate.notNull(ench, "Cannot add null enchantment");