Package com.plotsquared.core.player
Class MetaDataAccess<T>
java.lang.Object
com.plotsquared.core.player.MetaDataAccess<T>
- Type Parameters:
T
- Meta data type
- All Implemented Interfaces:
AutoCloseable
Access to player meta data
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
close()
get()
Get the stored meta data value@NonNull MetaDataKey<T>
Get the meta data key@NonNull PlotPlayer<?>
Get the owner of the meta databoolean
isClosed()
Check whether or not the meta data access has been closed.abstract boolean
Check if the player has meta data stored with the given keyabstract @Nullable T
remove()
Remove the stored value meta dataabstract void
Set the meta data value
-
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, orfalse
-
remove
Remove the stored value meta data- Returns:
- Old value, or
null
-
set
Set the meta data value- Parameters:
value
- New value
-
get
Get the stored meta data value- Returns:
- Stored value, or
Optional.empty()
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
-
getPlayer
Get the owner of the meta data- Returns:
- Player
-
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 toIllegalAccessException
being thrown- Returns:
true
if the access has been closed
-
checkClosed
protected void checkClosed()
-