Class Taggable<V extends IMetaContainer<V,P>,P extends org.bukkit.persistence.PersistentDataHolder>

java.lang.Object
com.marcusslover.plus.lib.common.Taggable<V,P>
All Implemented Interfaces:
IMetaContainer<Item,org.bukkit.inventory.meta.ItemMeta>
Direct Known Subclasses:
Item

public abstract class Taggable<V extends IMetaContainer<V,P>,P extends org.bukkit.persistence.PersistentDataHolder> extends Object implements IMetaContainer<Item,org.bukkit.inventory.meta.ItemMeta>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <K, Z> @NotNull Optional<Z>
    getTag(@NotNull String key, @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
    Get the value of the tag with the given key.
    boolean
    hasTag(@NotNull String key, @NotNull org.bukkit.persistence.PersistentDataType<?,?> type)
    Check if the item has a tag with the given key.
    protected abstract V
     
    removeTag(@NotNull String key)
    Remove the tag with the given key.
    <K, Z> V
    setTag(@NotNull String key, Z value, @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
    Set a tag to the item.
    <K, Z> @NotNull Optional<Z>
    tag(@NotNull String key, @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
     
    <K, Z> V
    tag(@NotNull String key, Z value, @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.marcusslover.plus.lib.common.IMetaContainer

    meta, meta, meta
  • Constructor Details

    • Taggable

      public Taggable()
  • Method Details

    • holder

      @NotNull protected abstract V holder()
    • tagHolder

      @NotNull public V tagHolder()
    • hasTag

      public boolean hasTag(@NotNull @NotNull String key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<?,?> type)
      Check if the item has a tag with the given key.
      Parameters:
      key - The key of the tag.
      type - The type of the tag.
      Returns:
      True if the item has the tag, false otherwise.
    • tag

      @NotNull public <K, Z> V tag(@NotNull @NotNull String key, @NotNull Z value, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
    • setTag

      @NotNull public <K, Z> V setTag(@NotNull @NotNull String key, @NotNull Z value, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
      Set a tag to the item.
      Type Parameters:
      K - The type of the value.
      Parameters:
      key - The key of the tag.
      value - The value of the tag.
      type - The type of the value. You can use DataType for all the default types.
      Returns:
      The holder.
    • tag

      @NotNull public <K, Z> @NotNull Optional<Z> tag(@NotNull @NotNull String key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
    • removeTag

      @NotNull public V removeTag(@NotNull @NotNull String key)
      Remove the tag with the given key.
      Parameters:
      key - The key of the tag.
      Returns:
      The holder.
    • getTag

      @NotNull public <K, Z> @NotNull Optional<Z> getTag(@NotNull @NotNull String key, @NotNull @NotNull org.bukkit.persistence.PersistentDataType<K,Z> type)
      Get the value of the tag with the given key.
      Type Parameters:
      K - The type of the value.
      Parameters:
      key - The key of the tag.
      type - The type of the value. You can use DataType for all the default types.
      Returns:
      The optional value of the tag. If the item doesn't have the tag, the optional will be empty.