public class ItemUtils
extends java.lang.Object
Constructor and Description |
---|
ItemUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
addItem(org.bukkit.inventory.Inventory inv,
org.bukkit.inventory.ItemStack is)
Adds the given item to the given inventory with the default max stack size
|
static int |
addItem(org.bukkit.inventory.Inventory inv,
org.bukkit.inventory.ItemStack is,
int maxStack)
Adds the given item to the given inventory
|
static org.bukkit.inventory.ItemStack |
addLore(org.bukkit.inventory.ItemStack is,
java.util.List<java.lang.String> lore,
java.lang.Object... vars) |
static org.bukkit.inventory.ItemStack |
addLore(org.bukkit.inventory.ItemStack is,
java.lang.String... lore) |
static org.bukkit.inventory.ItemStack |
addLoreStorageMeta(org.bukkit.inventory.ItemStack is,
java.lang.Object... values)
Adds the given lore storage meta to the given item
|
static boolean |
containsItem(java.lang.Iterable<org.bukkit.inventory.ItemStack> source,
org.bukkit.inventory.ItemStack is)
A truth check if an iterable contains the given typed item or not
|
static int |
countItem(org.bukkit.inventory.Inventory inv,
org.bukkit.inventory.ItemStack is)
Counts the given item in the given inventory
|
static int |
countItemSpace(org.bukkit.inventory.Inventory inv,
org.bukkit.inventory.ItemStack is,
int maxStack)
Counts the available space for the given item in the given inventory
|
static org.bukkit.inventory.ItemStack |
fillVariables(org.bukkit.inventory.ItemStack is,
java.lang.Object... vars)
Fill variables in a ItemStack
Available special variables:
#amount: the amount value of the item
#id: the id of the item
#sub: the subid of the item
|
static org.bukkit.inventory.ItemStack |
fillVariables(org.bukkit.entity.Player plr,
org.bukkit.inventory.ItemStack is) |
static org.bukkit.inventory.ItemStack |
getItem(java.lang.String name)
Get the numeric id of the given itemname, it works for both numeric and text ids.
|
static java.lang.String |
getLoreStorageMeta(org.bukkit.inventory.ItemStack is,
java.lang.String format,
java.lang.String def)
Gets the given lore storage meta from the given ItemStack
|
static java.lang.String |
getName(org.bukkit.inventory.ItemStack is)
Gets the name of the given item
|
static org.bukkit.inventory.ItemStack |
glow(org.bukkit.inventory.ItemStack item)
Makes item glowing by adding luck 1 enchant to it and hide enchants attribute
|
static boolean |
itemEqual(org.bukkit.inventory.ItemStack item1,
org.bukkit.inventory.ItemStack item2)
A truth check for two items, if they are actually totally same or not
|
static org.bukkit.inventory.ItemStack |
itemFromNBTJson(java.lang.String str)
Converts an NBT JSON String to an ItemStack
|
static boolean |
itemSimilar(org.bukkit.inventory.ItemStack item1,
org.bukkit.inventory.ItemStack item2)
A truth check for two items, if they type is actually totally same or not.
|
static java.lang.String |
itemToNBTJson(org.bukkit.inventory.ItemStack is)
Converts an item to NBT Json format
|
static java.lang.String |
itemToString(org.bukkit.inventory.ItemStack in)
Converts an ItemStack to it's representing string
|
static java.lang.String |
itemToString(org.bukkit.inventory.ItemStack in,
boolean useNBT)
Converts an ItemStack to it's representing string with the option to store all NBT tags of the item
|
static void |
loadInv(java.util.Map<java.lang.Integer,org.bukkit.inventory.ItemStack> map,
org.bukkit.inventory.Inventory inv)
Converts a map representation of a saved inventory to an actual Inventory.
|
static org.bukkit.inventory.ItemStack |
makeItem(org.bukkit.Material type,
int amount,
short sub,
java.lang.String name,
java.util.ArrayList<java.lang.String> lore,
java.lang.Object... vars) |
static org.bukkit.inventory.ItemStack |
makeItem(org.bukkit.Material type,
int amount,
short sub,
java.lang.String name,
java.lang.String... lore) |
static org.bukkit.inventory.ItemStack |
makeItem(org.bukkit.Material type,
java.lang.String name,
java.lang.String... lore) |
static int |
removeItem(org.bukkit.inventory.Inventory inv,
org.bukkit.inventory.ItemStack is)
Removes the given item from the given inventory
|
static java.util.TreeMap<java.lang.Integer,org.bukkit.inventory.ItemStack> |
saveInv(org.bukkit.inventory.Inventory inv)
Saves an inventory to a TreeMap containing the slots and the items of the given inventory
|
static org.bukkit.inventory.ItemStack |
stringToItemStack(java.lang.String in)
Converts an ItemStack representing string back to the ItemStack
|
public static int addItem(org.bukkit.inventory.Inventory inv, org.bukkit.inventory.ItemStack is)
inv
- - The inventory to which the item should be addedis
- - The addable itempublic static int addItem(org.bukkit.inventory.Inventory inv, org.bukkit.inventory.ItemStack is, int maxStack)
inv
- - The inventory to which the item should be addedis
- - The addable itemmaxStack
- - Maximal stack size of the itempublic static org.bukkit.inventory.ItemStack addLore(org.bukkit.inventory.ItemStack is, java.lang.String... lore)
public static org.bukkit.inventory.ItemStack addLore(org.bukkit.inventory.ItemStack is, java.util.List<java.lang.String> lore, java.lang.Object... vars)
public static org.bukkit.inventory.ItemStack addLoreStorageMeta(org.bukkit.inventory.ItemStack is, java.lang.Object... values)
is
- - Modifiable itemvalues
- - Array of storage format and valuespublic static boolean containsItem(java.lang.Iterable<org.bukkit.inventory.ItemStack> source, org.bukkit.inventory.ItemStack is)
source
- ItemStack iterableis
- checked ItemStackpublic static int countItem(org.bukkit.inventory.Inventory inv, org.bukkit.inventory.ItemStack is)
inv
- - The inventory in which the item should be countedis
- - The countable item, the amount of the item is ignored (calculated as 1)public static int countItemSpace(org.bukkit.inventory.Inventory inv, org.bukkit.inventory.ItemStack is, int maxStack)
inv
- - The inventory to which the item should be addedis
- - The addable itemmaxStack
- - Maximal stack size of the itempublic static org.bukkit.inventory.ItemStack fillVariables(org.bukkit.inventory.ItemStack is, java.lang.Object... vars)
is
- - The ItemStack in which the variables should be filledvars
- - The fillable variablespublic static org.bukkit.inventory.ItemStack fillVariables(org.bukkit.entity.Player plr, org.bukkit.inventory.ItemStack is)
public static org.bukkit.inventory.ItemStack getItem(java.lang.String name)
name
- the case insensitive material name of the item or the numeric id of the item.public static java.lang.String getLoreStorageMeta(org.bukkit.inventory.ItemStack is, java.lang.String format, java.lang.String def)
is
- - The checkable ItemStackformat
- - The format of the storage metadef
- - Default value to return if the meta was not found.public static java.lang.String getName(org.bukkit.inventory.ItemStack is)
is
- - The item which name we would like to getpublic static org.bukkit.inventory.ItemStack glow(org.bukkit.inventory.ItemStack item)
item
- - The glowable itempublic static boolean itemEqual(org.bukkit.inventory.ItemStack item1, org.bukkit.inventory.ItemStack item2)
item1
- first item of the equal checkingitem2
- second item of the equal checkingpublic static org.bukkit.inventory.ItemStack itemFromNBTJson(java.lang.String str)
str
- - Convertable NBT JSON Stringpublic static boolean itemSimilar(org.bukkit.inventory.ItemStack item1, org.bukkit.inventory.ItemStack item2)
item1
- first item of the similiar checkingitem2
- second item of the similiar checkingpublic static java.lang.String itemToNBTJson(org.bukkit.inventory.ItemStack is)
is
- - Convertable itempublic static java.lang.String itemToString(org.bukkit.inventory.ItemStack in)
in
- convertable ItemStackpublic static java.lang.String itemToString(org.bukkit.inventory.ItemStack in, boolean useNBT)
in
- - The convertable ItemStackuseNBT
- - Store every nbt tag of the itempublic static void loadInv(java.util.Map<java.lang.Integer,org.bukkit.inventory.ItemStack> map, org.bukkit.inventory.Inventory inv)
map
- - The map containing the items and their slots of the saved inventorypublic static org.bukkit.inventory.ItemStack makeItem(org.bukkit.Material type, int amount, short sub, java.lang.String name, java.lang.String... lore)
public static org.bukkit.inventory.ItemStack makeItem(org.bukkit.Material type, java.lang.String name, java.lang.String... lore)
public static org.bukkit.inventory.ItemStack makeItem(org.bukkit.Material type, int amount, short sub, java.lang.String name, java.util.ArrayList<java.lang.String> lore, java.lang.Object... vars)
public static int removeItem(org.bukkit.inventory.Inventory inv, org.bukkit.inventory.ItemStack is)
inv
- - The inventory from which the item should be removedis
- - The removable itempublic static java.util.TreeMap<java.lang.Integer,org.bukkit.inventory.ItemStack> saveInv(org.bukkit.inventory.Inventory inv)
inv
- - The saveable inventorypublic static org.bukkit.inventory.ItemStack stringToItemStack(java.lang.String in)
in
- string represantation of an ItemStack