2018-08-30 03:54:31 +02:00
|
|
|
From 2d6c06d66fa0bb54e1e769dc71adbb750c64225d Mon Sep 17 00:00:00 2001
|
2017-07-27 05:40:49 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Wed, 4 May 2016 23:55:48 -0400
|
|
|
|
Subject: [PATCH] ensureServerConversions API
|
|
|
|
|
|
|
|
This will take a Bukkit ItemStack and run it through any conversions a server process would perform on it,
|
|
|
|
to ensure it meets latest minecraft expectations.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
2018-08-30 03:54:31 +02:00
|
|
|
index ec2b8b8ed..3012aec22 100644
|
2017-07-27 05:40:49 +02:00
|
|
|
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
2018-07-14 03:44:35 +02:00
|
|
|
@@ -134,4 +134,16 @@ public interface ItemFactory {
|
2017-07-27 05:40:49 +02:00
|
|
|
*/
|
2018-07-14 03:44:35 +02:00
|
|
|
@Deprecated
|
|
|
|
Material updateMaterial(final ItemMeta meta, final Material material) throws IllegalArgumentException;
|
2017-07-27 05:40:49 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
|
|
|
+ * Minecart updates are converting simple item stacks into more complex NBT oriented Item Stacks.
|
|
|
|
+ *
|
|
|
|
+ * Use this method to to ensure any desired data conversions are processed.
|
|
|
|
+ * The input itemstack will not be the same as the returned itemstack.
|
|
|
|
+ *
|
|
|
|
+ * @param item The item to process conversions on
|
|
|
|
+ * @return A potentially Data Converted ItemStack
|
|
|
|
+ */
|
|
|
|
+ ItemStack ensureServerConversions(ItemStack item);
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
2018-08-30 03:54:31 +02:00
|
|
|
index c744799f6..5e8de1152 100644
|
2017-07-27 05:40:49 +02:00
|
|
|
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
2018-08-30 03:54:31 +02:00
|
|
|
@@ -506,7 +506,12 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
2018-07-19 06:42:43 +02:00
|
|
|
}
|
2017-07-27 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- return result;
|
2018-07-19 06:42:43 +02:00
|
|
|
+ // Set damage again incase meta overwrote it
|
|
|
|
+ if (args.containsKey("damage")) {
|
|
|
|
+ result.setDurability(damage);
|
|
|
|
+ }
|
|
|
|
+
|
2017-07-27 05:40:49 +02:00
|
|
|
+ return result.ensureServerConversions(); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-30 03:54:31 +02:00
|
|
|
@@ -564,4 +569,18 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
2017-07-27 05:40:49 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
|
|
|
+ * Minecart updates are converting simple item stacks into more complex NBT oriented Item Stacks.
|
|
|
|
+ *
|
|
|
|
+ * Use this method to to ensure any desired data conversions are processed.
|
|
|
|
+ * The input itemstack will not be the same as the returned itemstack.
|
|
|
|
+ *
|
|
|
|
+ * @return A potentially Data Converted ItemStack
|
|
|
|
+ */
|
|
|
|
+ public ItemStack ensureServerConversions() {
|
|
|
|
+ return Bukkit.getServer().getItemFactory().ensureServerConversions(this);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
--
|
2018-07-14 03:44:35 +02:00
|
|
|
2.18.0
|
2017-07-27 05:40:49 +02:00
|
|
|
|