Class MetaDataAccess<T>

java.lang.Object
com.plotsquared.core.player.MetaDataAccess<T>
Type Parameters:
T - Meta data type
All Implemented Interfaces:
AutoCloseable

public abstract class MetaDataAccess<T> extends Object implements AutoCloseable
Access to player meta data
  • Method Details

    • isPresent

      public abstract boolean isPresent()
      Check if the player has meta data stored with the given key
      Returns:
      true if player has meta data with this key, or false
    • remove

      public abstract @Nullable T remove()
      Remove the stored value meta data
      Returns:
      Old value, or null
    • set

      public abstract void set(@NonNull T value)
      Set the meta data value
      Parameters:
      value - New value
    • get

      public abstract @NonNull Optional<T> get()
      Get the stored meta data value
      Returns:
      Stored value, or Optional.empty()
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • getPlayer

      public @NonNull PlotPlayer<?> getPlayer()
      Get the owner of the meta data
      Returns:
      Player
    • getMetaDataKey

      public @NonNull MetaDataKey<T> getMetaDataKey()
      Get the meta data key
      Returns:
      Meta data key
    • isClosed

      public boolean isClosed()
      Check whether or not the meta data access has been closed. After being closed, all attempts to access the meta data through the instance, will lead to IllegalAccessException being thrown
      Returns:
      true if the access has been closed
    • checkClosed

      protected void checkClosed()