#690: Add method to read ItemStack input

By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
Bukkit/Spigot 2022-04-15 12:54:03 +10:00
parent 2d304809b5
commit dfc7a87b61
2 changed files with 30 additions and 0 deletions

View file

@ -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.
* <p>
* 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.

View file

@ -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.
* <p>
* 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.