public interface ItemFactory
Server.getItemFactory()
.
The ItemFactory is solely responsible for creating item meta containers to apply on item stacks.
Modifier and Type | Method and Description |
---|---|
net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowItem> |
asHoverEvent(@NotNull ItemStack item,
UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op)
Creates a hover event for the given item.
|
@Nullable ItemMeta |
asMetaFor(@NotNull ItemMeta meta,
@NotNull ItemStack stack)
Returns an appropriate item meta for the specified stack.
|
@Nullable ItemMeta |
asMetaFor(@NotNull ItemMeta meta,
@NotNull Material material)
Returns an appropriate item meta for the specified material.
|
net.kyori.adventure.text.Component |
displayName(@NotNull ItemStack itemStack)
Get the formatted display name of the
ItemStack . |
@NotNull ItemStack |
ensureServerConversions(@NotNull ItemStack item)
Minecart updates are converting simple item stacks into more complex NBT oriented Item Stacks.
|
boolean |
equals(@Nullable ItemMeta meta1,
@Nullable ItemMeta meta2)
This method is used to compare two item meta data objects.
|
@NotNull Color |
getDefaultLeatherColor()
Returns the default color for all leather armor.
|
@Nullable String |
getI18NDisplayName(@Nullable ItemStack item)
Gets the Display name as seen in the Client.
|
ItemMeta |
getItemMeta(@NotNull Material material)
This creates a new item meta for the material.
|
Content |
hoverContentOf(Entity entity)
Deprecated.
use
HoverEventSource.asHoverEvent() |
Content |
hoverContentOf(Entity entity,
BaseComponent customName)
Deprecated.
|
Content |
hoverContentOf(Entity entity,
BaseComponent[] customName)
Deprecated.
|
Content |
hoverContentOf(Entity entity,
@Nullable String customName)
Deprecated.
|
Content |
hoverContentOf(@NotNull ItemStack itemStack)
Creates a
Content of that ItemStack for displaying. |
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.
|
@NotNull Material |
updateMaterial(@NotNull ItemMeta meta,
@NotNull Material material)
Deprecated.
for internal use only
|
ItemMeta getItemMeta(@NotNull @NotNull Material material)
material
- The material to consider as base for the metaboolean isApplicable(@Nullable @Nullable ItemMeta meta, @Nullable @Nullable ItemStack stack) throws IllegalArgumentException
A SkullMeta
would not be valid for a sword, but a normal ItemMeta
from an enchanted dirt block would.
meta
- Meta to checkstack
- Item that meta will be applied toIllegalArgumentException
- if the meta was not created by this
factoryboolean isApplicable(@Nullable @Nullable ItemMeta meta, @Nullable @Nullable Material material) throws IllegalArgumentException
A SkullMeta
would not be valid for a sword, but a normal ItemMeta
from an enchanted dirt block would.
meta
- Meta to checkmaterial
- Material that meta will be applied toIllegalArgumentException
- if the meta was not created by this
factoryboolean equals(@Nullable @Nullable ItemMeta meta1, @Nullable @Nullable ItemMeta meta2) throws IllegalArgumentException
meta1
- First meta to compare, and may be null to indicate no datameta2
- Second meta to compare, and may be null to indicate no
dataIllegalArgumentException
- if either meta was not created by this
factory@Nullable @Nullable ItemMeta asMetaFor(@NotNull @NotNull ItemMeta meta, @NotNull @NotNull ItemStack stack) throws IllegalArgumentException
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
- the meta to convertstack
- the stack to convert the meta forIllegalArgumentException
- if the specified meta was not created
by this factory@Nullable @Nullable ItemMeta asMetaFor(@NotNull @NotNull ItemMeta meta, @NotNull @NotNull Material material) throws IllegalArgumentException
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
- the meta to convertmaterial
- the material to convert the meta forIllegalArgumentException
- if the specified meta was not created
by this factory@NotNull @NotNull Color getDefaultLeatherColor()
@Deprecated @NotNull @NotNull Material updateMaterial(@NotNull @NotNull ItemMeta meta, @NotNull @NotNull Material material) throws IllegalArgumentException
meta
- metamaterial
- materialIllegalArgumentException
- if bad material or data@NotNull net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(@NotNull @NotNull ItemStack item, @NotNull UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op)
item
- The item@NotNull net.kyori.adventure.text.Component displayName(@NotNull @NotNull ItemStack itemStack)
ItemStack
.@NotNull @NotNull ItemStack ensureServerConversions(@NotNull @NotNull ItemStack item)
item
- The item to process conversions on@Nullable @Nullable String getI18NDisplayName(@Nullable @Nullable ItemStack item)
item
- Item to return Display name of@NotNull Content hoverContentOf(@NotNull @NotNull ItemStack itemStack)
Content
of that ItemStack for displaying.itemStack
- Content
of that ItemStack@NotNull @Deprecated Content hoverContentOf(@NotNull Entity entity)
HoverEventSource.asHoverEvent()
@NotNull @Deprecated Content hoverContentOf(@NotNull Entity entity, @Nullable @Nullable String customName)
Entity.asHoverEvent(java.util.function.UnaryOperator)
@NotNull @Deprecated Content hoverContentOf(@NotNull Entity entity, @Nullable BaseComponent customName)
Entity.asHoverEvent(java.util.function.UnaryOperator)
@NotNull @Deprecated Content hoverContentOf(@NotNull Entity entity, @NotNull BaseComponent[] customName)
Entity.asHoverEvent(java.util.function.UnaryOperator)
Copyright © 2021. All rights reserved.