Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.inventory.ItemFactory Interface Reference

Public Member Functions

ItemMeta getItemMeta (final Material material)
 
boolean isApplicable (final ItemMeta meta, final ItemStack stack) throws IllegalArgumentException
 
boolean isApplicable (final ItemMeta meta, final Material material) throws IllegalArgumentException
 
boolean equals (final ItemMeta meta1, final ItemMeta meta2) throws IllegalArgumentException
 
ItemMeta asMetaFor (final ItemMeta meta, final ItemStack stack) throws IllegalArgumentException
 
ItemMeta asMetaFor (final ItemMeta meta, final Material material) throws IllegalArgumentException
 
Color getDefaultLeatherColor ()
 

Detailed Description

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.

Definition at line 17 of file ItemFactory.java.

Member Function Documentation

ItemMeta org.bukkit.inventory.ItemFactory.asMetaFor ( final ItemMeta  meta,
final ItemStack  stack 
) throws IllegalArgumentException

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.

Parameters
metathe meta to convert
stackthe stack to convert the meta for
Returns
An appropriate item meta for the specified item stack. No guarantees are made as to if a copy is returned. This will be null for a stack of air.
Exceptions
IllegalArgumentExceptionif the specified meta was not created by this factory

Referenced by org.bukkit.inventory.ItemStack.setTypeId().

ItemMeta org.bukkit.inventory.ItemFactory.asMetaFor ( final ItemMeta  meta,
final Material  material 
) throws IllegalArgumentException

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.

Parameters
metathe meta to convert
materialthe material to convert the meta for
Returns
An appropriate item meta for the specified item material. No guarantees are made as to if a copy is returned. This will be null for air.
Exceptions
IllegalArgumentExceptionif the specified meta was not created by this factory
boolean org.bukkit.inventory.ItemFactory.equals ( final ItemMeta  meta1,
final ItemMeta  meta2 
) throws IllegalArgumentException

This method is used to compare two item meta data objects.

Parameters
meta1First meta to compare, and may be null to indicate no data
meta2Second meta to compare, and may be null to indicate no data
Returns
false if one of the meta has data the other does not, otherwise true
Exceptions
IllegalArgumentExceptionif either meta was not created by this factory

Referenced by org.bukkit.inventory.ItemStack.hasItemMeta(), org.bukkit.inventory.ItemStack.isSimilar(), org.bukkit.inventory.ItemStack.serialize(), and org.bukkit.event.player.PlayerEditBookEvent.setNewBookMeta().

Color org.bukkit.inventory.ItemFactory.getDefaultLeatherColor ( )

Returns the default color for all leather armor.

Returns
the default color for leather armor
ItemMeta org.bukkit.inventory.ItemFactory.getItemMeta ( final Material  material)

This creates a new item meta for the material.

Parameters
materialThe material to consider as base for the meta
Returns
a new ItemMeta that could be applied to an item stack of the specified material

Referenced by org.bukkit.inventory.ItemStack.addUnsafeEnchantment(), and org.bukkit.inventory.ItemStack.getItemMeta().

boolean org.bukkit.inventory.ItemFactory.isApplicable ( final ItemMeta  meta,
final ItemStack  stack 
) throws IllegalArgumentException

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.

Parameters
metaMeta to check
stackItem that meta will be applied to
Returns
true if the meta can be applied without losing data, false otherwise
Exceptions
IllegalArgumentExceptionif the meta was not created by this factory
boolean org.bukkit.inventory.ItemFactory.isApplicable ( final ItemMeta  meta,
final Material  material 
) throws IllegalArgumentException

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.

Parameters
metaMeta to check
materialMaterial that meta will be applied to
Returns
true if the meta can be applied without losing data, false otherwise
Exceptions
IllegalArgumentExceptionif the meta was not created by this factory

The documentation for this interface was generated from the following file: