2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2017-07-27 03:40:49 +00: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-02-21 19:45:33 +00:00
|
|
|
index 3dba4c361993e143e511b4f108ac0b444a84d964..30ab5d38197bccfc06f6f5554b162f8bdbfe2a45 100644
|
2017-07-27 03:40:49 +00:00
|
|
|
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
2021-02-21 19:45:33 +00:00
|
|
|
@@ -151,5 +151,17 @@ public interface ItemFactory {
|
|
|
|
*/
|
2019-03-20 00:28:15 +00:00
|
|
|
@NotNull
|
2021-02-21 19:45:33 +00:00
|
|
|
net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(final @NotNull ItemStack item, final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op);
|
|
|
|
+
|
2017-07-27 03:40:49 +00: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 00:28:15 +00:00
|
|
|
+ @NotNull
|
|
|
|
+ ItemStack ensureServerConversions(@NotNull ItemStack item);
|
2021-02-21 19:45:33 +00:00
|
|
|
// Paper end
|
2017-07-27 03:40:49 +00:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
2021-02-21 19:45:33 +00:00
|
|
|
index 4b20b557eaa958cf1ad1baf8d6cc17f38b180ff1..c31f667c466ba80bd88ae560d14dbd18a84118b4 100644
|
2017-07-27 03:40:49 +00:00
|
|
|
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
2021-02-21 19:45:33 +00:00
|
|
|
@@ -536,7 +536,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
|
2018-07-19 04:42:43 +00:00
|
|
|
}
|
2017-07-27 03:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- return result;
|
|
|
|
+ return result.ensureServerConversions(); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-21 19:45:33 +00:00
|
|
|
@@ -602,5 +602,18 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
|
|
|
|
public net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op) {
|
|
|
|
return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op);
|
2017-07-27 03:40:49 +00: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 00:28:15 +00:00
|
|
|
+ @NotNull
|
2017-07-27 03:40:49 +00:00
|
|
|
+ public ItemStack ensureServerConversions() {
|
|
|
|
+ return Bukkit.getServer().getItemFactory().ensureServerConversions(this);
|
|
|
|
+ }
|
2021-02-21 19:45:33 +00:00
|
|
|
// Paper end
|
2017-07-27 03:40:49 +00:00
|
|
|
}
|