Interface Metadatable

All Known Subinterfaces:
Actor, MapMetadatable, Player
All Known Implementing Classes:
AbstractCommandBlockActor, AbstractNonPlayerActor, AbstractPlayerActor, AsyncPlayer, LocationMaskedPlayerWrapper, PlayerProxy, SilentPlayerWrapper

public interface Metadatable
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <V> V
    Deletes the given metadata key from object.
    <T> T
    getAndSetMeta(String key, T value)
     
    <V> V
    Gets the metadata value to which the specified key is mapped, or null if the key is not set.
    default <V> V
    getMeta(String key, V defaultValue)
    Gets the metadata value to which the specified key is mapped, or the default value if no metadata exists for the key.
    boolean
    Checks if the object contains any metadata.
    void
    setMeta(String key, Object value)
    Set some session only metadata for the player
  • Method Details

    • setMeta

      void setMeta(String key, Object value)
      Set some session only metadata for the player
      Parameters:
      key -
      value -
    • getAndSetMeta

      <T> T getAndSetMeta(String key, T value)
    • hasMeta

      boolean hasMeta()
      Checks if the object contains any metadata.
      Returns:
      true if there is metadata set for the object
    • getMeta

      <V> V getMeta(String key)
      Gets the metadata value to which the specified key is mapped, or null if the key is not set.
      Parameters:
      key - the key of the metadata value to retrieve
      Returns:
      the value of the metadata or null if none exists
    • getMeta

      @Nonnull default <V> V getMeta(String key, @Nonnull V defaultValue)
      Gets the metadata value to which the specified key is mapped, or the default value if no metadata exists for the key.
      Parameters:
      key - the key of the metadata value to retrieve
      defaultValue - the value to return if there is no metadata for the given key
      Returns:
      the metadata value for the key, if present; else the default value
    • deleteMeta

      @Nullable <V> V deleteMeta(String key)
      Deletes the given metadata key from object. Do not delete metadata set by another plugin unless you know what you are doing.
      Parameters:
      key - the key identifying the metadata to remove.
      Returns:
      the previous value associated with they given key