Class DataBlock

java.lang.Object
redempt.redlib.blockdata.DataBlock

public class DataBlock extends Object
Represents a Block with various data attached to it
  • Field Details

    • data

      protected JSONMap data
    • exists

      protected boolean exists
  • Constructor Details

    • DataBlock

      protected DataBlock(org.bukkit.block.Block block, BlockDataManager manager)
  • Method Details

    • getTransientProperty

      public Object getTransientProperty(String key)
      Gets a transient property associated with the given key
      Parameters:
      key - The key
      Returns:
      The transient property
    • removeTransientProperty

      public void removeTransientProperty(String key)
      Removes a transient property by its key
      Parameters:
      key - The key of the transient property
    • setTransientProperty

      public void setTransientProperty(String key, Object o)
      Attaches a transient property to this DataBlock. Transient properties are not saved and will be lost if the chunk is unloaded or the server is stopped
      Parameters:
      key - The key of the transient property
      o - The value of the transient property
    • setTransientPropertyIfAbsent

      public void setTransientPropertyIfAbsent(String key, Object o)
      Attaches a transient property, if absent, to this DataBlock. Transient properties are not saved and will be lost if the chunk is unloaded or the server is stopped
      Parameters:
      key - The key of the transient property
      o - The value of the transient property
    • containsTransientProperty

      public boolean containsTransientProperty(String key)
      Checks to see if a transient property is associated with the key provided.
      Parameters:
      key - The key
      Returns:
      true if this DataBlock contains a transient property for the specified key
    • set

      public void set(String key, Object data)
      Sets a data value in this DataBlock. If this is the first piece of data attached to this DataBlock, it will be added to the map of the BlockDataManager it was created by.
      Parameters:
      key - The key to put the data at
      data - The data to put
    • setIfAbsent

      public void setIfAbsent(String key, Object data)
      Sets a data value, if absent, in this DataBlock. If this is the first piece of data attached to this DataBlock, it will be added to the map of the BlockDataManager it was created by.
      Parameters:
      key - The key to put the data at
      data - The data to put
    • setData

      protected void setData(JSONMap data)
    • get

      public Object get(String key)
      Gets the object mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The object mapped to the key
    • getInt

      public int getInt(String key)
      Gets an int mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The int mapped to the key
    • getString

      public String getString(String key)
      Gets a String mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The String mapped to the key
    • getBoolean

      public boolean getBoolean(String key)
      Gets a boolean mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The boolean mapped to the key
    • getDouble

      public double getDouble(String key)
      Gets a double mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The double mapped to the key
    • getLong

      public long getLong(String key)
      Gets a double mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The double mapped to the key
    • getMap

      public JSONMap getMap(String key)
      Gets a JSONMap mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The JSONMap mapped to the key
    • getList

      public JSONList getList(String key)
      Gets a JSONList mapped to a certain key
      Parameters:
      key - The key
      Returns:
      The JSONList mapped to the key
    • remove

      public void remove(String key)
      Removes the object associated with a certain key. If this object is the last one stored in this DataBlock, this DataBlock will be removed from its BlockDataManager.
      Parameters:
      key - The key
    • contains

      public boolean contains(String key)
      Checks to see if an object is associated with the key provided.
      Parameters:
      key - The key
      Returns:
      true if this DataBlock contains an object for the specified key
    • clear

      public void clear()
      Removes all of the data from this block.
    • move

      public void move(org.bukkit.block.Block block)
      Moves the data in this DataBlock to a new Block
      Parameters:
      block - The Block to move the data to
    • getData

      public JSONMap getData()
      Returns:
      All the data stored in this DataBlock
    • save

      protected void save()
    • isLoaded

      public boolean isLoaded()
      Returns:
      Whether the chunk this DataBlock is in is loaded
    • getChunkCoordinates

      public int[] getChunkCoordinates()
      Returns:
      The chunk coordinates [x, z] of this DataBlock
    • getWorld

      public org.bukkit.World getWorld()
      Returns:
      The World this DataBlock is in
    • remove

      public void remove()
      Removes this DataBlock and all the data associated with it
    • getBlock

      public org.bukkit.block.Block getBlock()
      Returns:
      The Block this DataBlock stores data for
    • getManager

      public BlockDataManager getManager()
      Returns:
      The BlockDataManager managing this DataBlock
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object