2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 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
|
2021-05-13 08:16:33 +02:00
|
|
|
index 6cc4bad2ecd19f44a680ff03cbfb99d48ea5c337..845119c9ba9dc2719dc67b0edb0ff2ad58656bde 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
|
2021-05-13 08:16:33 +02:00
|
|
|
@@ -160,5 +160,17 @@ public interface ItemFactory {
|
2021-02-21 20:45:33 +01:00
|
|
|
*/
|
2019-03-20 01:28:15 +01:00
|
|
|
@NotNull
|
2021-05-13 08:16:33 +02:00
|
|
|
net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack);
|
2021-02-21 20:45:33 +01:00
|
|
|
+
|
2017-07-27 05:40:49 +02:00
|
|
|
+ /**
|
|
|
|
+ * 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
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
|
|
|
+ ItemStack ensureServerConversions(@NotNull ItemStack item);
|
2021-02-21 20:45:33 +01:00
|
|
|
// Paper end
|
2017-07-27 05:40:49 +02:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
2021-05-13 08:16:33 +02:00
|
|
|
index a15abec467bac70116a6fc21a300d4930b909f15..1c69ca6a6d0e956d796827159236ee3466813d0e 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
|
2021-02-21 20:45:33 +01:00
|
|
|
@@ -536,7 +536,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
|
2018-07-19 06:42:43 +02:00
|
|
|
}
|
2017-07-27 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- return result;
|
|
|
|
+ return result.ensureServerConversions(); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-05-13 08:16:33 +02:00
|
|
|
@@ -611,5 +611,18 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
|
|
|
|
public @NotNull net.kyori.adventure.text.Component displayName() {
|
|
|
|
return Bukkit.getServer().getItemFactory().displayName(this);
|
2017-07-27 05:40:49 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 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
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2017-07-27 05:40:49 +02:00
|
|
|
+ public ItemStack ensureServerConversions() {
|
|
|
|
+ return Bukkit.getServer().getItemFactory().ensureServerConversions(this);
|
|
|
|
+ }
|
2021-02-21 20:45:33 +01:00
|
|
|
// Paper end
|
2017-07-27 05:40:49 +02:00
|
|
|
}
|