Interface ItemFactory
Server.getItemFactory()
.
The ItemFactory is solely responsible for creating item meta containers to apply on item stacks.
-
Method Summary
Modifier and TypeMethodDescriptionasHoverEvent(@NotNull ItemStack item, UnaryOperator<HoverEvent.ShowItem> op)
Creates a hover event for the given item.Returns an appropriate item meta for the specified stack.Returns an appropriate item meta for the specified material.displayName(@NotNull ItemStack itemStack)
Get the formatted display name of theItemStack
.Minecraft updates are converting simple item stacks into more complex NBT oriented Item Stacks.boolean
This method is used to compare two item meta data objects.Returns the default color for all leather armor.getI18NDisplayName(@Nullable ItemStack item)
Gets the Display name as seen in the Client.getItemMeta(@NotNull Material material)
This creates a new item meta for the material.hoverContentOf(@NotNull ItemStack itemStack)
Creates aContent
of that ItemStack for displaying.hoverContentOf(Entity entity)
Deprecated.hoverContentOf(Entity entity, @NotNull BaseComponent[] customName)
Deprecated.hoverContentOf(Entity entity, @Nullable String customName)
Deprecated.hoverContentOf(Entity entity, BaseComponent customName)
Deprecated.boolean
isApplicable(@Nullable ItemMeta meta, @Nullable ItemStack stack)
This method checks the item meta to confirm that it is applicable (no data lost if applied) to the specified ItemStack.boolean
isApplicable(@Nullable ItemMeta meta, @Nullable Material material)
This method checks the item meta to confirm that it is applicable (no data lost if applied) to the specified Material.updateMaterial(@NotNull ItemMeta meta, @NotNull Material material)
Deprecated.for internal use only
-
Method Details
-
getItemMeta
This creates a new item meta for the material.- Parameters:
material
- The material to consider as base for the meta- Returns:
- a new ItemMeta that could be applied to an item stack of the specified material
-
isApplicable
boolean isApplicable(@Nullable @Nullable ItemMeta meta, @Nullable @Nullable ItemStack stack) throws IllegalArgumentExceptionThis 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 normalItemMeta
from an enchanted dirt block would.- Parameters:
meta
- Meta to checkstack
- Item that meta will be applied to- Returns:
- true if the meta can be applied without losing data, false otherwise
- Throws:
IllegalArgumentException
- if the meta was not created by this factory
-
isApplicable
boolean isApplicable(@Nullable @Nullable ItemMeta meta, @Nullable @Nullable Material material) throws IllegalArgumentExceptionThis 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 normalItemMeta
from an enchanted dirt block would.- Parameters:
meta
- Meta to checkmaterial
- Material that meta will be applied to- Returns:
- true if the meta can be applied without losing data, false otherwise
- Throws:
IllegalArgumentException
- if the meta was not created by this factory
-
equals
boolean equals(@Nullable @Nullable ItemMeta meta1, @Nullable @Nullable ItemMeta meta2) throws IllegalArgumentExceptionThis method is used to compare two item meta data objects.- Parameters:
meta1
- First meta to compare, and may be null to indicate no datameta2
- Second 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
- Throws:
IllegalArgumentException
- if either meta was not created by this factory
-
asMetaFor
@Nullable @Nullable ItemMeta asMetaFor(@NotNull @NotNull ItemMeta meta, @NotNull @NotNull ItemStack stack) throws IllegalArgumentExceptionReturns 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 aBookMeta
containing all information in the specified meta that is applicable to anItemMeta
, the highest common interface.- Parameters:
meta
- the meta to convertstack
- the 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.
- Throws:
IllegalArgumentException
- if the specified meta was not created by this factory
-
asMetaFor
@Nullable @Nullable ItemMeta asMetaFor(@NotNull @NotNull ItemMeta meta, @NotNull @NotNull Material material) throws IllegalArgumentExceptionReturns 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 aBookMeta
containing all information in the specified meta that is applicable to anItemMeta
, the highest common interface.- Parameters:
meta
- the meta to convertmaterial
- the 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.
- Throws:
IllegalArgumentException
- if the specified meta was not created by this factory
-
getDefaultLeatherColor
Returns the default color for all leather armor.- Returns:
- the default color for leather armor
-
updateMaterial
@Deprecated @NotNull @NotNull Material updateMaterial(@NotNull @NotNull ItemMeta meta, @NotNull @NotNull Material material) throws IllegalArgumentExceptionDeprecated.for internal use onlyApply a material change for an item meta. Do not use under any circumstances.- Parameters:
meta
- metamaterial
- material- Returns:
- updated material
- Throws:
IllegalArgumentException
- if bad material or data
-
asHoverEvent
@NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull @NotNull ItemStack item, @NotNull UnaryOperator<HoverEvent.ShowItem> op)Creates a hover event for the given item.- Parameters:
item
- The item- Returns:
- A hover event
-
displayName
Get the formatted display name of theItemStack
. -
ensureServerConversions
Minecraft updates are converting simple item stacks into more complex NBT oriented Item Stacks. Use this method to to ensure any desired data conversions are processed. The input itemstack will not be the same as the returned itemstack.- Parameters:
item
- The item to process conversions on- Returns:
- A potentially Data Converted ItemStack
-
getI18NDisplayName
Gets the Display name as seen in the Client. Currently the server only supports the English language. To override this, You must replace the language file embedded in the server jar.- Parameters:
item
- Item to return Display name of- Returns:
- Display name of Item
-
hoverContentOf
Creates aContent
of that ItemStack for displaying.- Parameters:
itemStack
-- Returns:
- the
Content
of that ItemStack
-
hoverContentOf
Deprecated. -
hoverContentOf
@NotNull @Deprecated Content hoverContentOf(@NotNull Entity entity, @Nullable @Nullable String customName)Deprecated. -
hoverContentOf
@NotNull @Deprecated Content hoverContentOf(@NotNull Entity entity, @Nullable BaseComponent customName)Deprecated. -
hoverContentOf
@NotNull @Deprecated Content hoverContentOf(@NotNull Entity entity, @NotNull @NotNull BaseComponent[] customName)Deprecated.
-
HoverEventSource.asHoverEvent()