QuarterBukkit

ItemData

The ItemData class stores the data of item stacks and blocks globally. You can e.g. compare the material and data values of blocks and item stacks simply without writing long if-statements. You can also modify the stored data after the creation. Furthermore, the class contains several utility methods.

Utility

The ItemData-class contains some utility-methods for simply comparating the datas of different item stacks or blocks:

public static boolean equals(ItemStack itemStack1, ItemStack itemStack2)
public static boolean equals(Block block1, Block block2)
public static boolean equals(final ItemStack itemStack1, final Block block2)

Creation

You can use several constructors for creating an item data object and filling it with data:

public ItemData()
public ItemData(Material material)
public ItemData(Material material, byte data)
public ItemData(ItemStack itemStack)
public ItemData(Block block)

Get and Set Data

You can read the stored data or modify it with a couple of methods:

public Material getMaterial()
public void setMaterial(Material material)
public byte getData()
public void setData(byte data)

Equals

You can check if the datas of the item data object and another item data object, an item stack or a block are the same:

public boolean equals(ItemData itemData)
public boolean equals(ItemStack itemStack)
public boolean equals(Block block)

Contains

You can check precisely if an inventory contains an item stack with the data of the object:

public boolean contains(Inventory inventory)

Contains at Least

You can also check precisely if an inventory contains at least a given amount of item stacks with the data of the object:

public boolean containsAtLeast(Inventory inventory, int minimumAmount)