Class WGMetadata

java.lang.Object
com.sk89q.worldguard.bukkit.internal.WGMetadata

public final class WGMetadata extends Object
Utility methods for dealing with metadata on entities.

WorldGuard is placed as the owner of all values.

  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    getIfPresent(org.bukkit.metadata.Metadatable target, String key, Class<T> expected)
    Get the (first) metadata value on the given target that has the given key and is of the given class type.
    static void
    put(org.bukkit.metadata.Metadatable target, String key, Object value)
    Add some metadata to a target.
    static void
    remove(org.bukkit.metadata.Metadatable target, String key)
    Removes metadata from the target.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • put

      public static void put(org.bukkit.metadata.Metadatable target, String key, Object value)
      Add some metadata to a target.
      Parameters:
      target - the target
      key - the key
      value - the value
    • getIfPresent

      @Nullable public static <T> T getIfPresent(org.bukkit.metadata.Metadatable target, String key, Class<T> expected)
      Get the (first) metadata value on the given target that has the given key and is of the given class type.
      Type Parameters:
      T - the type of the value
      Parameters:
      target - the target
      key - the key
      expected - the type of the value
      Returns:
      a value, or null if one does not exists
    • remove

      public static void remove(org.bukkit.metadata.Metadatable target, String key)
      Removes metadata from the target.
      Parameters:
      target - the target
      key - the key