Class MetadataMap

java.lang.Object
net.glowstone.entity.meta.MetadataMap
All Implemented Interfaces:
DynamicallyTypedMap<MetadataIndex>, DynamicallyTypedMapWithFloats<MetadataIndex>

public class MetadataMap extends Object implements DynamicallyTypedMapWithFloats<MetadataIndex>
A map for entity metadata.
  • Constructor Details

    • MetadataMap

      public MetadataMap(Class<? extends org.bukkit.entity.Entity> entityClass)
  • Method Details

    • containsKey

      public boolean containsKey(MetadataIndex index)
    • set

      public void set(MetadataIndex index, Object value)
      Sets the value of a metadata field.
      Parameters:
      index - the field to set
      value - the new value
    • set

      public void set(MetadataIndex index, Object value, boolean force)
      Sets the value of a metadata field.
      Parameters:
      index - the field to set
      value - the new value
      force - if the value should be forced as a change regardless of equality
    • get

      public Object get(MetadataIndex index)
    • getBit

      public boolean getBit(MetadataIndex index, int bit)
      Tests for the given bit mask in a bit field.
      Parameters:
      index - the field to test
      bit - a mask of the bits to test
    • setBit

      public void setBit(MetadataIndex index, int bit, boolean status)
      Sets or clears bits in a bit field.
      Parameters:
      index - the field to update
      bit - a mask of the bits to set or clear
      status - true to set; false to clear
    • getNumber

      public Number getNumber(MetadataIndex index)
      Returns the numeric value of a metadata field.
      Parameters:
      index - the field to look up
      Returns:
      the numeric value
      Throws:
      IllegalArgumentException - if the value doesn't exist or isn't numeric
    • getBoolean

      public boolean getBoolean(MetadataIndex index)
      Description copied from interface: DynamicallyTypedMap
      Retrieves an entry as a boolean.
      Specified by:
      getBoolean in interface DynamicallyTypedMap<MetadataIndex>
      Parameters:
      index - the key to look up
      Returns:
      the value as a boolean
    • getByte

      public byte getByte(MetadataIndex index)
    • getInt

      public int getInt(MetadataIndex index)
      Description copied from interface: DynamicallyTypedMap
      Retrieves an entry as an int.
      Specified by:
      getInt in interface DynamicallyTypedMap<MetadataIndex>
      Parameters:
      index - the key to look up
      Returns:
      the value as an int
    • getFloat

      public float getFloat(MetadataIndex index)
      Description copied from interface: DynamicallyTypedMapWithFloats
      Retrieves an entry as a float.
      Specified by:
      getFloat in interface DynamicallyTypedMapWithFloats<MetadataIndex>
      Parameters:
      index - the key to look up
      Returns:
      the value as a float
    • getString

      public String getString(MetadataIndex index)
      Description copied from interface: DynamicallyTypedMap
      Retrieves an entry as a String.
      Specified by:
      getString in interface DynamicallyTypedMap<MetadataIndex>
      Parameters:
      index - the key to look up
      Returns:
      the value as a String
    • getItem

      public org.bukkit.inventory.ItemStack getItem(MetadataIndex index)
    • getOptPosition

      public org.bukkit.util.BlockVector getOptPosition(MetadataIndex index)
      Gets the optional position value for the given MetadataIndex.
      Parameters:
      index - the MetadataIndex of the optional position
      Returns:
      the position value as a BlockVector, null if the value is not present
    • getChat

      public TextMessage getChat(MetadataIndex index)
    • getOptChat

      public TextMessage getOptChat(MetadataIndex index)
      Gets the optional chat value for the given MetadataIndex.
      Parameters:
      index - the MetadataIndex of the optional chat
      Returns:
      the chat value as a TextMessage, null if the value is not present
    • getEntryList

      public List<MetadataMap.Entry> getEntryList()
      Returns a list containing copies of all the entries.
      Returns:
      a list containing copies of all the entries
    • getChanges

      public List<MetadataMap.Entry> getChanges()
    • resetChanges

      public void resetChanges()
    • toString

      public String toString()
      Overrides:
      toString in class Object