2018-07-26 01:05:07 +02:00
|
|
|
From 7a4550bdfee62eaba02e50fe3434310cb0b82f8c 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-07-15 03:53:17 +02:00
|
|
|
index 762c43d6..045c26d9 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-07-26 01:05:07 +02:00
|
|
|
index 3c91cbe6..4940e726 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-07-26 01:05:07 +02:00
|
|
|
@@ -495,7 +495,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-07-26 01:05:07 +02:00
|
|
|
@@ -553,4 +558,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
|
|
|
|