程序包 org.bukkit.metadata

# 类 MetadataStoreBase<T>

java.lang.Object
org.bukkit.metadata.MetadataStoreBase<T>

public abstract class MetadataStoreBase<T> extends Object

- ## 构造器概要

  构造器
  构造器
  说明
  `MetadataStoreBase()`

- ## 方法概要

  修饰符和类型
  方法
  说明
  `protected abstract @NotNull String`
  `disambiguate(T subject, @NotNull String metadataKey)`
  Creates a unique name for the object receiving metadata by combining unique data from the subject with a metadataKey.
  `@NotNull List<MetadataValue>`
  `getMetadata(T subject, @NotNull String metadataKey)`
  Returns all metadata values attached to an object.
  `boolean`
  `hasMetadata(T subject, @NotNull String metadataKey)`
  Tests to see if a metadata attribute has been set on an object.
  `void`
  `invalidateAll(@NotNull Plugin owningPlugin)`
  Invalidates all metadata in the metadata store that originates from the given plugin.
  `void`
  `removeMetadata(T subject, @NotNull String metadataKey, @NotNull Plugin owningPlugin)`
  Removes a metadata item owned by a plugin from a subject.
  `void`
  `setMetadata(T subject, @NotNull String metadataKey, @NotNull MetadataValue newMetadataValue)`
  Adds a metadata value to an object.

  ### 从类继承的方法 java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 构造器详细资料

  - ### MetadataStoreBase

    public MetadataStoreBase()

- ## 方法详细资料

  - ### setMetadata

    public void setMetadata(@NotNull T subject, @NotNull @NotNull String metadataKey, @NotNull @NotNull MetadataValue newMetadataValue)
    Adds a metadata value to an object. Each metadata value is owned by a specific `Plugin`. If a plugin has already added a metadata value to an object, that value will be replaced with the value of `newMetadataValue`. Multiple plugins can set independent values for the same `metadataKey` without conflict.

    Implementation note: I considered using a `ReadWriteLock` for controlling access to `metadataMap`, 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
    另请参阅:
      - `MetadataStore.setMetadata(Object, String, MetadataValue)`

  - ### getMetadata

    @NotNull public @NotNull List<MetadataValue> getMetadata(@NotNull T subject, @NotNull @NotNull String metadataKey)
    Returns all metadata values attached to an object. If multiple have attached metadata, each will value will be included.
    参数:
      `subject` - the object being interrogated.
      `metadataKey` - the unique metadata key being sought.
    返回:
      A list of values, one for each plugin that has set the requested value.
    另请参阅:
      - `MetadataStore.getMetadata(Object, String)`

  - ### hasMetadata

    public boolean hasMetadata(@NotNull T subject, @NotNull @NotNull 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.
    返回:
      the existence of the metadataKey within subject.

  - ### removeMetadata

    public void removeMetadata(@NotNull T subject, @NotNull @NotNull String metadataKey, @NotNull @NotNull 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
    另请参阅:
      - `MetadataStore.removeMetadata(Object, String, org.bukkit.plugin.Plugin)`

  - ### invalidateAll

    public void invalidateAll(@NotNull @NotNull 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
    另请参阅:
      - `MetadataStore.invalidateAll(org.bukkit.plugin.Plugin)`

  - ### disambiguate

    @NotNull protected abstract @NotNull String disambiguate(@NotNull T subject, @NotNull @NotNull String metadataKey)
    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.
    返回:
      a unique metadata key for the given subject.