summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-08-25 22:27:13 +1000
committermd_5 <git@md-5.net>2018-08-25 22:27:13 +1000
commit23c1a2ba03b96b52f69a93e07706f9ccc33fd683 (patch)
tree83d33be3111e0f4322159fff4268f2b58157b277
parent07ae1eea99b17f678fa014520229af561c3a09f6 (diff)
downloadbukkit-23c1a2ba03b96b52f69a93e07706f9ccc33fd683.tar
bukkit-23c1a2ba03b96b52f69a93e07706f9ccc33fd683.tar.gz
bukkit-23c1a2ba03b96b52f69a93e07706f9ccc33fd683.tar.lz
bukkit-23c1a2ba03b96b52f69a93e07706f9ccc33fd683.tar.xz
bukkit-23c1a2ba03b96b52f69a93e07706f9ccc33fd683.zip
Deprecate ItemStack durability methods in favour of ItemMeta Damageable as they are being frequently used incorrectly.
-rw-r--r--src/main/java/org/bukkit/inventory/ItemStack.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index 89ab4725..2e44d4e2 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -51,6 +51,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
* @param type item material
* @param amount stack size
* @param damage durability / damage
+ * @deprecated see {@link #setDurability(short)}
*/
public ItemStack(final Material type, final int amount, final short damage) {
this(type, amount, damage, null);
@@ -177,7 +178,13 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
* Sets the durability of this item
*
* @param durability Durability of this item
+ * @deprecated durability is now part of ItemMeta. To avoid confusion and
+ * misuse, {@link #getItemMeta()}, {@link #setItemMeta(ItemMeta)} and
+ * {@link Damageable#setDamage(int)} should be used instead. This is because
+ * any call to this method will be overwritten by subsequent setting of
+ * ItemMeta which was created before this call.
*/
+ @Deprecated
public void setDurability(final short durability) {
ItemMeta meta = getItemMeta();
if (meta != null) {
@@ -190,7 +197,9 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
* Gets the durability of this item
*
* @return Durability of this item
+ * @deprecated see {@link #setDurability(short)}
*/
+ @Deprecated
public short getDurability() {
ItemMeta meta = getItemMeta();
return (meta == null) ? 0 : (short) ((Damageable) meta).getDamage();