public class ItemStack extends java.lang.Object implements java.lang.Cloneable, ConfigurationSerializable
限定符 | 构造器和说明 |
---|---|
protected |
ItemStack() |
|
ItemStack(int type)
已过时。
不安全的参数
|
|
ItemStack(int type,
int amount)
已过时。
不安全的参数
|
|
ItemStack(int type,
int amount,
short damage)
已过时。
不安全的参数
|
|
ItemStack(int type,
int amount,
short damage,
java.lang.Byte data)
已过时。
该方法使用了意义不明确的data byte对象
|
|
ItemStack(ItemStack stack)
构造一个指定物品堆的副本.
|
|
ItemStack(Material type)
构造一个堆叠数为1, 无附加数据的物品堆.
|
|
ItemStack(Material type,
int amount)
构造指定堆叠数, 无附加数据的物品堆.
|
|
ItemStack(Material type,
int amount,
short damage)
构造一个具有指定损耗值(耐久度)的物品堆.
|
|
ItemStack(Material type,
int amount,
short damage,
java.lang.Byte data)
已过时。
该方法使用了意义不明确的data byte对象
|
限定符和类型 | 方法和说明 |
---|---|
void |
addEnchantment(Enchantment ench,
int level)
向物品堆添加
附魔 . |
void |
addEnchantments(java.util.Map<Enchantment,java.lang.Integer> enchantments)
向物品堆添加附魔.
|
void |
addUnsafeEnchantment(Enchantment ench,
int level)
向物品堆添加
附魔 . |
void |
addUnsafeEnchantments(java.util.Map<Enchantment,java.lang.Integer> enchantments)
以不安全的方式向物品堆添加附魔.
|
ItemStack |
clone() |
boolean |
containsEnchantment(Enchantment ench)
检测该物品堆是否包含指定
附魔 . |
static ItemStack |
deserialize(java.util.Map<java.lang.String,java.lang.Object> args)
实现配置序列化与反序列化需要的方法.
|
boolean |
equals(java.lang.Object obj) |
int |
getAmount()
获取该物品堆的物品堆叠数量.
|
MaterialData |
getData()
获取该物品堆的 MateralData 数据.
|
short |
getDurability()
获取该物品的耐久度.
|
int |
getEnchantmentLevel(Enchantment ench)
获取该物品指定附魔的附魔等级.
|
java.util.Map<Enchantment,java.lang.Integer> |
getEnchantments()
获取该物品的所有附魔以及对应的附魔等级, 用map表示.
|
ItemMeta |
getItemMeta()
获取此物品堆的
ItemMeta 的副本. |
int |
getMaxStackSize()
获取该物品的最大堆叠数 (若物品未知返回-1).
|
Material |
getType()
获取该物品的种类.
|
int |
getTypeId()
已过时。
不安全的参数
|
int |
hashCode() |
boolean |
hasItemMeta()
检测该物品堆是否含有任何物品元数据.
|
boolean |
isSimilar(ItemStack stack)
该方法与equals方法相同, 但不考虑堆叠数量.
|
int |
removeEnchantment(Enchantment ench)
移除指定的
附魔 . |
java.util.Map<java.lang.String,java.lang.Object> |
serialize()
Creates a Map representation of this class.
|
void |
setAmount(int amount)
设置该物品堆的物品堆叠数量.
|
void |
setData(MaterialData data)
设置该物品堆的 MateralData 数据.
|
void |
setDurability(short durability)
设置该物品的耐久度.
|
boolean |
setItemMeta(ItemMeta itemMeta)
向物品堆设置元数据.
|
void |
setType(Material type)
设置该物品的种类.
|
void |
setTypeId(int type)
已过时。
不安全的参数
|
java.lang.String |
toString() |
protected ItemStack()
@Deprecated public ItemStack(int type)
原文:Defaults stack size to 1, with no extra data
type
- 物品material idpublic ItemStack(Material type)
原文:Defaults stack size to 1, with no extra data
type
- 物品种类@Deprecated public ItemStack(int type, int amount)
原文:An item stack with no extra data
type
- 物品material idamount
- 堆叠数public ItemStack(Material type, int amount)
原文:An item stack with no extra data
type
- 物品种类amount
- 堆叠数@Deprecated public ItemStack(int type, int amount, short damage)
原文:An item stack with the specified damage / durability
type
- 物品material idamount
- 堆叠数damage
- 损耗值/耐久度public ItemStack(Material type, int amount, short damage)
原文:An item stack with the specified damage / durability
type
- 物品种类amount
- 堆叠数damage
- 损耗值@Deprecated public ItemStack(int type, int amount, short damage, java.lang.Byte data)
type
- the raw type idamount
- the amount in the stackdamage
- the damage value of the itemdata
- the data value or null@Deprecated public ItemStack(Material type, int amount, short damage, java.lang.Byte data)
type
- the typeamount
- the amount in the stackdamage
- the damage value of the itemdata
- the data value or nullpublic ItemStack(ItemStack stack) throws java.lang.IllegalArgumentException
原文:Creates a new item stack derived from the specified stack
stack
- 要复制的物品堆java.lang.IllegalArgumentException
- 如果指定的 stack 为null或返回的
物品元数据不是通过ItemFactory创建的public Material getType()
原文:Gets the type of this item
public void setType(Material type)
注:在做这件事的同时你将清除该物品堆上的MaterialData数据.
原文:Sets the type of this item
Note that in doing so you will reset the MaterialData for this stack
type
- 该物品的种类@Deprecated public int getTypeId()
原文:Gets the type id of this item
@Deprecated public void setTypeId(int type)
注:在做这件事的同时你将清除该物品堆上的MaterialData数据.
原文:Sets the type id of this item
Note that in doing so you will reset the MaterialData for this stack
type
- 物品idpublic int getAmount()
原文:Gets the amount of items in this stack
public void setAmount(int amount)
原文:Sets the amount of items in this stack
amount
- 物品堆叠数量public MaterialData getData()
原文:Gets the MaterialData for this stack of items
public void setData(MaterialData data)
原文:Sets the MaterialData for this stack of items
data
- 物品堆的MaterialData数据public void setDurability(short durability)
原文:Sets the durability of this item
durability
- 物品耐久度public short getDurability()
原文:Gets the durability of this item
public int getMaxStackSize()
原文:Get the maximum stacksize for the material hold in this ItemStack. (Returns -1 if it has no idea)
public java.lang.String toString()
toString
在类中 java.lang.Object
public boolean equals(java.lang.Object obj)
equals
在类中 java.lang.Object
public boolean isSimilar(ItemStack stack)
原文:This method is the same as equals, but does not consider stack size (amount).
stack
- 与哪个物品堆作比较public ItemStack clone()
clone
在类中 java.lang.Object
public int hashCode()
hashCode
在类中 java.lang.Object
public boolean containsEnchantment(Enchantment ench)
附魔
.
原文:Checks if this ItemStack contains the given Enchantment
ench
- 附魔public int getEnchantmentLevel(Enchantment ench)
原文:Gets the level of the specified enchantment on this item stack
ench
- 附魔public java.util.Map<Enchantment,java.lang.Integer> getEnchantments()
原文:Gets a map containing all enchantments and their levels on this item.
public void addEnchantments(java.util.Map<Enchantment,java.lang.Integer> enchantments)
该方法实质就是遍历你所给的map, 逐一调用addEnchantment(org.bukkit.enchantments.Enchantment, int)
.
原文:Adds the specified enchantments to this item stack.
This method is the same as calling addEnchantment(org.bukkit.enchantments.Enchantment, int)
for each
element of the map.
enchantments
- 要添加的附魔java.lang.IllegalArgumentException
- 若参数enchantments为nulljava.lang.IllegalArgumentException
- 若任何指定的附魔或等级为null.
警告: 某些附魔可能会在此异常抛出前添加到此物品上public void addEnchantment(Enchantment ench, int level)
附魔
.
若此物品堆已经含有给定的附魔(无论它们的附魔等级是什么), 将替换已有的附魔.
原文:Adds the specified Enchantment
to this item stack.
If this item stack already contained the given enchantment (at any level), it will be replaced.
ench
- 附魔level
- 附魔等级java.lang.IllegalArgumentException
- 若enchantment为null, 或该附魔不可应用于此物品上public void addUnsafeEnchantments(java.util.Map<Enchantment,java.lang.Integer> enchantments)
该方法实质就是遍历你所给的map, 逐一调用addUnsafeEnchantment(org.bukkit.enchantments.Enchantment, int)
.
原文:Adds the specified enchantments to this item stack in an unsafe manner.
This method is the same as calling addUnsafeEnchantment(org.bukkit.enchantments.Enchantment, int)
for
each element of the map.
enchantments
- 附魔public void addUnsafeEnchantment(Enchantment ench, int level)
附魔
.
若此物品堆已经含有给定的附魔(无论它们的附魔等级是什么), 将替换已有的附魔.
该方法是个不安全操作, 忽略附魔的等级限制以及对此物品的可用性. 请慎重使用.
原文:Adds the specified 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
- 附魔level
- 附魔等级public int removeEnchantment(Enchantment ench)
附魔
.
原文:Removes the specified Enchantment
if it exists on this
ItemStack
ench
- 要移除的附魔public java.util.Map<java.lang.String,java.lang.Object> serialize()
ConfigurationSerializable
This class must provide a method to restore this class, as defined in
the ConfigurationSerializable
interface javadocs.
serialize
在接口中 ConfigurationSerializable
public static ItemStack deserialize(java.util.Map<java.lang.String,java.lang.Object> args)
原文:Required method for configuration serialization
args
- 需要反序列化的mapConfigurationSerializable
public ItemMeta getItemMeta()
public boolean hasItemMeta()
原文:Checks to see if any meta data has been defined.
public boolean setItemMeta(ItemMeta itemMeta)
原文:Set the ItemMeta of this ItemStack.
itemMeta
- 新物品元数据,或用null来清除此物品上的元数据ItemFactory.isApplicable(ItemMeta, ItemStack)
java.lang.IllegalArgumentException
- 物品元数据不是通过ItemFactory
创建的