![]() |
Bukkit
1.4.7-R1.0
|
Public Member Functions | |
| synchronized void | setMetadata (T subject, String metadataKey, MetadataValue newMetadataValue) |
| Adds a metadata value to an object. | |
| synchronized List< MetadataValue > | getMetadata (T subject, String metadataKey) |
| Returns all metadata values attached to an object. | |
| synchronized boolean | hasMetadata (T subject, String metadataKey) |
| Tests to see if a metadata attribute has been set on an object. | |
| synchronized void | removeMetadata (T subject, String metadataKey, Plugin owningPlugin) |
| Removes a metadata item owned by a plugin from a subject. | |
| synchronized void | invalidateAll (Plugin owningPlugin) |
| Invalidates all metadata in the metadata store that originates from the given plugin. | |
Protected Member Functions | |
| abstract String | disambiguate (T subject, String metadataKey) |
| Creates a unique name for the object receiving metadata by combining unique data from the subject with a metadataKey. | |
Definition at line 8 of file MetadataStoreBase.java.
|
protectedpure virtual |
Creates a unique name for the object receiving metadata by combining unique data from the subject with a metadataKey.
The name created must be globally unique for the given object and any two equivalent objects must generate the same unique name. For example, two Player objects must generate the same string if they represent the same player, even if the objects would fail a reference equality test.
| subject | The object for which this key is being generated. |
| metadataKey | The name identifying the metadata value. |
| synchronized List<MetadataValue> org.bukkit.metadata.MetadataStoreBase< T >.getMetadata | ( | T | subject, |
| String | metadataKey | ||
| ) |
Returns all metadata values attached to an object.
If multiple plugins have attached metadata, each will value will be included.
| subject | the object being interrogated. |
| metadataKey | the unique metadata key being sought. |
Definition at line 57 of file MetadataStoreBase.java.
| synchronized boolean org.bukkit.metadata.MetadataStoreBase< T >.hasMetadata | ( | T | subject, |
| String | metadataKey | ||
| ) |
Tests to see if a metadata attribute has been set on an object.
| subject | the object upon which the has-metadata test is performed. |
| metadataKey | the unique metadata key being queried. |
Definition at line 73 of file MetadataStoreBase.java.
| synchronized void org.bukkit.metadata.MetadataStoreBase< T >.invalidateAll | ( | Plugin | owningPlugin | ) |
Invalidates all metadata in the metadata store that originates from the given plugin.
Doing this will force each invalidated metadata item to be recalculated the next time it is accessed.
| owningPlugin | the plugin requesting the invalidation. |
| IllegalArgumentException | If plugin is null |
Definition at line 110 of file MetadataStoreBase.java.
| synchronized void org.bukkit.metadata.MetadataStoreBase< T >.removeMetadata | ( | T | subject, |
| String | metadataKey, | ||
| Plugin | owningPlugin | ||
| ) |
Removes a metadata item owned by a plugin from a subject.
| subject | the object to remove the metadata from. |
| metadataKey | the unique metadata key identifying the metadata to remove. |
| owningPlugin | the plugin attempting to remove a metadata item. |
| IllegalArgumentException | If plugin is null |
Definition at line 87 of file MetadataStoreBase.java.
| synchronized void org.bukkit.metadata.MetadataStoreBase< T >.setMetadata | ( | T | subject, |
| String | metadataKey, | ||
| MetadataValue | newMetadataValue | ||
| ) |
Adds a metadata value to an object.
Each metadata value is owned by a specificPlugin. If a plugin has already added a metadata value to an object, that value will be replaced with the value of
. Multiple plugins can set independent values for the same
without conflict.
Implementation note: I considered using a java.util.concurrent.locks.ReadWriteLock for controlling access to
, but decided that the added overhead wasn't worth the finer grained access control. Bukkit is almost entirely single threaded so locking overhead shouldn't pose a problem.
| subject | The object receiving the metadata. |
| metadataKey | A unique key to identify this metadata. |
| newMetadataValue | The metadata value to apply. |
| IllegalArgumentException | If value is null, or the owning plugin is null |
Definition at line 28 of file MetadataStoreBase.java.
References org.bukkit.metadata.MetadataValue.getOwningPlugin().