|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.inventory.ItemStack
public class ItemStack
Represents a stack of items
Constructor Summary | |
---|---|
protected |
ItemStack()
|
|
ItemStack(int type)
Deprecated. Magic value |
|
ItemStack(int type,
int amount)
Deprecated. Magic value |
|
ItemStack(int type,
int amount,
short damage)
Deprecated. Magic value |
|
ItemStack(int type,
int amount,
short damage,
Byte data)
Deprecated. this method uses an ambiguous data byte object |
|
ItemStack(ItemStack stack)
Creates a new item stack derived from the specified stack |
|
ItemStack(Material type)
Defaults stack size to 1, with no extra data |
|
ItemStack(Material type,
int amount)
An item stack with no extra data |
|
ItemStack(Material type,
int amount,
short damage)
An item stack with the specified damage / durabiltiy |
|
ItemStack(Material type,
int amount,
short damage,
Byte data)
Deprecated. this method uses an ambiguous data byte object |
Method Summary | |
---|---|
void |
addEnchantment(Enchantment ench,
int level)
Adds the specified Enchantment to this item stack. |
void |
addEnchantments(Map<Enchantment,Integer> enchantments)
Adds the specified enchantments to this item stack. |
void |
addUnsafeEnchantment(Enchantment ench,
int level)
Adds the specified Enchantment to this item stack. |
void |
addUnsafeEnchantments(Map<Enchantment,Integer> enchantments)
Adds the specified enchantments to this item stack in an unsafe manner. |
ItemStack |
clone()
|
boolean |
containsEnchantment(Enchantment ench)
Checks if this ItemStack contains the given Enchantment |
static ItemStack |
deserialize(Map<String,Object> args)
Required method for configuration serialization |
boolean |
equals(Object obj)
|
int |
getAmount()
Gets the amount of items in this stack |
MaterialData |
getData()
Gets the MaterialData for this stack of items |
short |
getDurability()
Gets the durability of this item |
int |
getEnchantmentLevel(Enchantment ench)
Gets the level of the specified enchantment on this item stack |
Map<Enchantment,Integer> |
getEnchantments()
Gets a map containing all enchantments and their levels on this item. |
ItemMeta |
getItemMeta()
Get a copy of this ItemStack's ItemMeta . |
int |
getMaxStackSize()
Get the maximum stacksize for the material hold in this ItemStack. |
Material |
getType()
Gets the type of this item |
int |
getTypeId()
Deprecated. Magic value |
int |
hashCode()
|
boolean |
hasItemMeta()
Checks to see if any meta data has been defined. |
boolean |
isSimilar(ItemStack stack)
This method is the same as equals, but does not consider stack size (amount). |
int |
removeEnchantment(Enchantment ench)
Removes the specified Enchantment if it exists on this
ItemStack |
Map<String,Object> |
serialize()
Creates a Map representation of this class. |
void |
setAmount(int amount)
Sets the amount of items in this stack |
void |
setData(MaterialData data)
Sets the MaterialData for this stack of items |
void |
setDurability(short durability)
Sets the durability of this item |
boolean |
setItemMeta(ItemMeta itemMeta)
Set the ItemMeta of this ItemStack. |
void |
setType(Material type)
Sets the type of this item |
void |
setTypeId(int type)
Deprecated. Magic value |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected ItemStack()
@Deprecated public ItemStack(int type)
type
- item material idpublic ItemStack(Material type)
type
- item material@Deprecated public ItemStack(int type, int amount)
type
- item material idamount
- stack sizepublic ItemStack(Material type, int amount)
type
- item materialamount
- stack size@Deprecated public ItemStack(int type, int amount, short damage)
type
- item material idamount
- stack sizedamage
- durability / damagepublic ItemStack(Material type, int amount, short damage)
type
- item materialamount
- stack sizedamage
- durability / damage@Deprecated public ItemStack(int type, int amount, short damage, Byte data)
@Deprecated public ItemStack(Material type, int amount, short damage, Byte data)
public ItemStack(ItemStack stack) throws IllegalArgumentException
stack
- the stack to copy
IllegalArgumentException
- if the specified stack is null or
returns an item meta not created by the item factoryMethod Detail |
---|
public Material getType()
public void setType(Material type)
Note that in doing so you will reset the MaterialData for this stack
type
- New type to set the items in this stack to@Deprecated public int getTypeId()
@Deprecated public void setTypeId(int type)
Note that in doing so you will reset the MaterialData for this stack
type
- New type id to set the items in this stack topublic int getAmount()
public void setAmount(int amount)
amount
- New amount of items in this stackpublic MaterialData getData()
public void setData(MaterialData data)
data
- New MaterialData for this itempublic void setDurability(short durability)
durability
- Durability of this itempublic short getDurability()
public int getMaxStackSize()
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
public boolean isSimilar(ItemStack stack)
stack
- the item stack to compare to
public ItemStack clone()
clone
in class Object
public final int hashCode()
hashCode
in class Object
public boolean containsEnchantment(Enchantment ench)
Enchantment
ench
- Enchantment to test
public int getEnchantmentLevel(Enchantment ench)
ench
- Enchantment to check
public Map<Enchantment,Integer> getEnchantments()
public void addEnchantments(Map<Enchantment,Integer> enchantments)
This method is the same as calling addEnchantment(org.bukkit.enchantments.Enchantment, int)
for each
element of the map.
enchantments
- Enchantments to add
IllegalArgumentException
- if the specified enchantments is null
IllegalArgumentException
- if any specific enchantment or level
is null. Warning: Some enchantments may be added before this
exception is thrown.public void addEnchantment(Enchantment ench, int level)
Enchantment
to this item stack.
If this item stack already contained the given enchantment (at any level), it will be replaced.
ench
- Enchantment to addlevel
- Level of the enchantment
IllegalArgumentException
- if enchantment null, or enchantment is
not applicablepublic void addUnsafeEnchantments(Map<Enchantment,Integer> enchantments)
This method is the same as calling addUnsafeEnchantment(org.bukkit.enchantments.Enchantment, int)
for
each element of the map.
enchantments
- Enchantments to addpublic void addUnsafeEnchantment(Enchantment ench, int level)
Enchantment
to this item stack.
If this item stack already contained the given enchantment (at any level), it will be replaced.
This method is unsafe and will ignore level restrictions or item type. Use at your own discretion.
ench
- Enchantment to addlevel
- Level of the enchantmentpublic int removeEnchantment(Enchantment ench)
Enchantment
if it exists on this
ItemStack
ench
- Enchantment to remove
public Map<String,Object> serialize()
ConfigurationSerializable
This class must provide a method to restore this class, as defined in
the ConfigurationSerializable
interface javadocs.
serialize
in interface ConfigurationSerializable
public static ItemStack deserialize(Map<String,Object> args)
args
- map to deserialize
ConfigurationSerializable
public ItemMeta getItemMeta()
ItemMeta
.
public boolean hasItemMeta()
public boolean setItemMeta(ItemMeta itemMeta)
itemMeta
- new ItemMeta, or null to indicate meta data be cleared.
ItemFactory.isApplicable(ItemMeta, ItemStack)
IllegalArgumentException
- if the item meta was not created by
the ItemFactory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |