Package net.citizensnpcs.api.npc
Class SimpleMetadataStore
java.lang.Object
net.citizensnpcs.api.npc.SimpleMetadataStore
- All Implemented Interfaces:
MetadataStore
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Copies the metadata store.<T> T
Fetches metadata from the given key.<T> T
Fetches metadata from the given key.<T> T
get
(NPC.Metadata key) Fetches metadata from the given key.<T> T
get
(NPC.Metadata key, T def) Fetches metadata from the given key.boolean
Returns whether the metadata exists.boolean
has
(NPC.Metadata key) Returns whether the metadata exists.void
Loads persistent metadata from the givenDataKey
.void
Removes any metadata at the given metadata key.void
remove
(NPC.Metadata key) Removes any metadata at the given metadata key.void
Saves persistent metadata to the givenDataKey
.void
Stores data at the given key.void
set
(NPC.Metadata key, Object data) Stores data at the given key.void
setPersistent
(String key, Object data) Stores data at the given key.void
setPersistent
(NPC.Metadata key, Object data) Stores data at the given key.int
size()
-
Constructor Details
-
SimpleMetadataStore
public SimpleMetadataStore()
-
-
Method Details
-
clone
Description copied from interface:MetadataStore
Copies the metadata store.- Specified by:
clone
in interfaceMetadataStore
- Overrides:
clone
in classObject
-
get
Description copied from interface:MetadataStore
Fetches metadata from the given key.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- The key to get metadata from- Returns:
- The metadata at the given key, or null if not found
-
get
Description copied from interface:MetadataStore
Fetches metadata from the given key.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- The key to get metadata fromdef
- The default value to return- Returns:
- The metadata at the given key, or def if not found
-
get
Description copied from interface:MetadataStore
Fetches metadata from the given key.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- The key to get metadata from- Returns:
- The metadata at the given key, or null if not found
-
get
Description copied from interface:MetadataStore
Fetches metadata from the given key. Sets the default value provided viaMetadataStore.set(String, Object)
if the metadata is not already stored.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- The key to get metadata fromdef
- The default value to return- Returns:
- The metadata at the given key, or def if not found
-
has
Description copied from interface:MetadataStore
Returns whether the metadata exists.- Specified by:
has
in interfaceMetadataStore
- Parameters:
key
- The metadata key- Returns:
- Whether the metadata exists
-
has
Description copied from interface:MetadataStore
Returns whether the metadata exists.- Specified by:
has
in interfaceMetadataStore
- Parameters:
key
- The metadata key- Returns:
- Whether the metadata exists
-
loadFrom
Description copied from interface:MetadataStore
Loads persistent metadata from the givenDataKey
.- Specified by:
loadFrom
in interfaceMetadataStore
- Parameters:
key
- The key to load from
-
remove
Description copied from interface:MetadataStore
Removes any metadata at the given metadata key.- Specified by:
remove
in interfaceMetadataStore
- Parameters:
key
- The metadata key
-
remove
Description copied from interface:MetadataStore
Removes any metadata at the given metadata key.- Specified by:
remove
in interfaceMetadataStore
- Parameters:
key
- The metadata key
-
saveTo
Description copied from interface:MetadataStore
Saves persistent metadata to the givenDataKey
.- Specified by:
saveTo
in interfaceMetadataStore
- Parameters:
key
- The key to save to.
-
set
Description copied from interface:MetadataStore
Stores data at the given key. Data will not persist.- Specified by:
set
in interfaceMetadataStore
- Parameters:
key
- The metadata keydata
- The data to store
-
set
Description copied from interface:MetadataStore
Stores data at the given key. Data will not persist.- Specified by:
set
in interfaceMetadataStore
- Parameters:
key
- The metadata keydata
- The data to store
-
setPersistent
Description copied from interface:MetadataStore
Stores data at the given key. Data will persist and must be a primitive type orString
.- Specified by:
setPersistent
in interfaceMetadataStore
- Parameters:
key
- The metadata keydata
- The data to store
-
setPersistent
Description copied from interface:MetadataStore
Stores data at the given key. Data will persist and must be a primitive type orString
.- Specified by:
setPersistent
in interfaceMetadataStore
- Parameters:
key
- The metadata keydata
- The data to store
-
size
public int size()- Specified by:
size
in interfaceMetadataStore
- Returns:
- The number of elements in the store
-