public interface ItemFactory
Server.getItemFactory()
来获得.
ItemFactory类用于创建物品元数据以应用在物品上.
译者注: 本类中的元数据意为ItemMeta
原文: An instance of the ItemFactory can be obtained with Server.getItemFactory()
.
The ItemFactory is solely responsible for creating item meta containers to apply on item stacks.
限定符和类型 | 方法和说明 |
---|---|
ItemMeta |
asMetaFor(ItemMeta meta,
ItemStack stack)
返回一个适用于给定的ItemStack的ItemMeta
返回的元数据将始终是指定材质的给定ItemStack的有效元数据.
|
ItemMeta |
asMetaFor(ItemMeta meta,
Material material)
返回一个适用于给定的Material的ItemMeta
返回的元数据将始终是指定材质的给定
Material 的有效元数据. |
boolean |
equals(ItemMeta meta1,
ItemMeta meta2)
该方法用于比较两个ItemStack的元数据对象.
|
Color |
getDefaultLeatherColor()
返回所有皮甲的默认颜色.
|
ItemMeta |
getItemMeta(Material material)
该方法能够为给定的
Material 创建一个新的元数据。 |
boolean |
isApplicable(ItemMeta meta,
ItemStack stack)
该方法用于检查元数据是否能够适用于指定的ItemStack上(如果适用则物品不会丢失之前的数据).
|
boolean |
isApplicable(ItemMeta meta,
Material material)
该方法用于检查元数据是否能够适用于指定的
Material 上(如果适用则不会丢失数据). |
ItemMeta getItemMeta(Material material)
Material
创建一个新的元数据。
原文: This creates a new item meta for the material.
boolean isApplicable(ItemMeta meta, ItemStack stack) throws java.lang.IllegalArgumentException
一个SkullMeta
对于一把剑来说是无效的, 但是一个普通的附魔泥土块的ItemMeta
会有效。
原文: This method checks the item meta to confirm that it is applicable (no
data lost if applied) to the specified ItemStack.
A SkullMeta
would not be valid for a sword, but a normal ItemMeta
from an enchanted dirt block would.
meta
- 需要检查的元数据stack
- 元数据将应用于的ItemStackjava.lang.IllegalArgumentException
- 如果元数据不是由ItemFactory创建出来的则抛出此异常boolean isApplicable(ItemMeta meta, Material material) throws java.lang.IllegalArgumentException
Material
上(如果适用则不会丢失数据).
一个SkullMeta
对于一把剑来说是无效的, 但是一个普通的附魔泥土块的ItemMeta
会有效。
原文: This method checks the item meta to confirm that it is applicable (no data lost if applied) to the specified Material.
A SkullMeta
would not be valid for a sword, but a normal ItemMeta
from an enchanted dirt block would.
meta
- 需要检查的元数据material
- 元数据将应用于的Materialjava.lang.IllegalArgumentException
- 如果元数据不是由ItemFactory创建出来的则抛出此异常boolean equals(ItemMeta meta1, ItemMeta meta2) throws java.lang.IllegalArgumentException
原文: This method is used to compare two item meta data objects.
meta1
- 第一个要比较的元数据, 元数据为null则表明没有数据meta2
- 第二个要比较的元数据, 元数据为null则表明没有数据java.lang.IllegalArgumentException
- 如果两个元数据都不是由ItemFactory创建出来的则抛出此异常ItemMeta asMetaFor(ItemMeta meta, ItemStack stack) throws java.lang.IllegalArgumentException
返回的元数据将始终是指定材质的给定ItemStack的有效元数据. 它可能是一个或多或少的特定元数据,也可以是与参数相同的元数据或元类型. 返回的ItemMeta始终是最适用的Meta
例子:
如果将SkullMeta
作应用于书本,
此方法将返回包含指定Meta的所有数据的BookMeta
,
该数据适用于最高公共接口ItemMeta
.
原文: Returns an appropriate item meta for the specified stack.
The item meta returned will always be a valid meta for a given ItemStack of the specified material. It may be a more or less specific meta, and could also be the same meta or meta type as the parameter. The item meta returned will also always be the most appropriate meta.
Example, if a SkullMeta
is being applied to a book, this method
would return a BookMeta
containing all information in the
specified meta that is applicable to an ItemMeta
, the highest
common interface.
meta
- 需要转换的元数据stack
- 给定的ItemStackjava.lang.IllegalArgumentException
- 如果元数据不是由ItemFactory创建出来的则抛出此异常ItemMeta asMetaFor(ItemMeta meta, Material material) throws java.lang.IllegalArgumentException
返回的元数据将始终是指定材质的给定Material
的有效元数据.
它可能是一个或多或少的特定元数据,也可以是与参数相同的元数据或元类型.
返回的ItemMeta始终是最适用的Meta
例子:
如果将SkullMeta
作应用于书本,
此方法将返回包含指定Meta的所有数据的BookMeta
,
该数据适用于最高公共接口ItemMeta
.
原文: Returns an appropriate item meta for the specified material.
The item meta returned will always be a valid meta for a given ItemStack of the specified material. It may be a more or less specific meta, and could also be the same meta or meta type as the parameter. The item meta returned will also always be the most appropriate meta.
Example, if a SkullMeta
is being applied to a book, this method
would return a BookMeta
containing all information in the
specified meta that is applicable to an ItemMeta
, the highest
common interface.
meta
- 需要转换的ItemMetamaterial
- 给定的Materialjava.lang.IllegalArgumentException
- 如果元数据不是由ItemFactory创建出来的则抛出此异常Color getDefaultLeatherColor()
原文: Returns the default color for all leather armor.