public interface CustomItemTagContainer
Modifier and Type | Method | Description |
---|---|---|
ItemTagAdapterContext |
getAdapterContext() |
Returns the adapter context this tag container uses.
|
<T,Z> Z |
getCustomTag(NamespacedKey key,
ItemTagType<T,Z> type) |
Returns the custom tag's value that is stored on the item.
|
<T,Z> boolean |
hasCustomTag(NamespacedKey key,
ItemTagType<T,Z> type) |
Returns if the item meta has a custom tag registered matching the
provided parameters.
|
boolean |
isEmpty() |
Returns if the container instance is empty, therefore has no entries
inside it.
|
void |
removeCustomTag(NamespacedKey key) |
Removes a custom key from the item meta.
|
<T,Z> void |
setCustomTag(NamespacedKey key,
ItemTagType<T,Z> type,
Z value) |
Stores a custom value on the
ItemMeta . |
<T,Z> void setCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType<T,Z> type, @NotNull Z value)
ItemMeta
.
This API cannot be used to manipulate minecraft tags, as the values will
be stored using your namespace. This method will override any existing
value the meta may have stored under the provided key.T
- the generic java type of the tag valueZ
- the generic type of the object to storekey
- the key this value will be stored undertype
- the type this item tag usesvalue
- the value stored in the tagNullPointerException
- if the key is nullNullPointerException
- if the type is nullNullPointerException
- if the value is null. Removing a custom tag
should be done using removeCustomTag(org.bukkit.NamespacedKey)
IllegalArgumentException
- if no suitable adapter will be found for
the ItemTagType.getPrimitiveType()
<T,Z> boolean hasCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType<T,Z> type)
ItemTagType
implementation will
not store the complex data type. Therefore storing a UUID (by storing a
byte[]) will match hasCustomTag("key" , ItemTagType.BYTE_ARRAY
).
Likewise a stored byte[] will always match your UUID ItemTagType
even if it is not 16 bytes long.
This method is only usable for custom object keys. Overwriting existing
tags, like the the display name, will not work as the values are stored
using your namespace.T
- the generic type of the stored primitiveZ
- the generic type of the eventually created complex objectkey
- the key the value is stored undertype
- the type which primitive storage type has to match the valueNullPointerException
- if the key to look up is nullNullPointerException
- if the type to cast the found object to is
null@Nullable <T,Z> Z getCustomTag(@NotNull NamespacedKey key, @NotNull ItemTagType<T,Z> type)
T
- the generic type of the stored primitiveZ
- the generic type of the eventually created complex objectkey
- the key to look up in the custom tag maptype
- the type the value must have and will be casted tonull
if no value was mapped under the given
valueNullPointerException
- if the key to look up is nullNullPointerException
- if the type to cast the found object to is
nullIllegalArgumentException
- if the value exists under the given key,
but cannot be access using the given typeIllegalArgumentException
- if no suitable adapter will be found for
the ItemTagType.getPrimitiveType()
void removeCustomTag(@NotNull NamespacedKey key)
key
- the keyNullPointerException
- if the provided key is nullboolean isEmpty()
@NotNull ItemTagAdapterContext getAdapterContext()
Copyright © 2020. All rights reserved.