diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java b/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java index 4ff149fd98..f89d71b77d 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -3,6 +3,7 @@ package org.bukkit.inventory; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.Server; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; @@ -128,6 +129,23 @@ public interface ItemFactory { @NotNull Color getDefaultLeatherColor(); + /** + * Create a new {@link ItemStack} given the supplied input. + *

+ * The input should match the same input as expected by Minecraft's {@code /give} + * command. For example, "minecraft:diamond_sword{Enchantments:[{id:"minecraft:sharpness", lvl:3}]}" + * would yield an ItemStack of {@link Material#DIAMOND_SWORD} with an {@link ItemMeta} + * containing a level 3 {@link Enchantment#DAMAGE_ALL} + * enchantment. + * + * @param input the item input string + * @return the created ItemStack + * @throws IllegalArgumentException if the input string was provided in an + * invalid or unsupported format + */ + @NotNull + ItemStack createItemStack(@NotNull String input) throws IllegalArgumentException; + /** * Apply a material change for an item meta. Do not use under any * circumstances. diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index f2e9f2753e..91eee1470f 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java @@ -358,6 +358,18 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste */ boolean removeAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier); + /** + * Get this ItemMeta as an NBT string. + *

+ * This string should not be relied upon as a serializable value. If + * serialization is desired, the {@link ConfigurationSerializable} API + * should be used instead. + * + * @return the NBT string + */ + @NotNull + String getAsString(); + /** * Returns a public custom tag container capable of storing tags on the * item.