Package redempt.redlib.blockdata
Class DataBlock
java.lang.Object
redempt.redlib.blockdata.DataBlock
Represents a Block with various data attached to it
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataBlock(org.bukkit.block.Block block, BlockDataManager manager) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all of the data from this block.booleanChecks to see if an object is associated with the key provided.booleanChecks to see if a transient property is associated with the key provided.booleanGets the object mapped to a certain keyorg.bukkit.block.BlockgetBlock()booleangetBoolean(String key) Gets a boolean mapped to a certain keyint[]getData()doubleGets a double mapped to a certain keyintGets an int mapped to a certain keyGets a JSONList mapped to a certain keylongGets a double mapped to a certain keyGets a JSONMap mapped to a certain keyGets a String mapped to a certain keyGets a transient property associated with the given keyorg.bukkit.WorldgetWorld()inthashCode()booleanisLoaded()voidmove(org.bukkit.block.Block block) Moves the data in this DataBlock to a new Blockvoidremove()Removes this DataBlock and all the data associated with itvoidRemoves the object associated with a certain key.voidRemoves a transient property by its keyprotected voidsave()voidSets a data value in this DataBlock.protected voidvoidsetIfAbsent(String key, Object data) Sets a data value, if absent, in this DataBlock.voidsetTransientProperty(String key, Object o) Attaches a transient property to this DataBlock.voidsetTransientPropertyIfAbsent(String key, Object o) Attaches a transient property, if absent, to this DataBlock.
-
Field Details
-
data
-
exists
protected boolean exists
-
-
Constructor Details
-
DataBlock
-
-
Method Details
-
getTransientProperty
Gets a transient property associated with the given key- Parameters:
key- The key- Returns:
- The transient property
-
removeTransientProperty
Removes a transient property by its key- Parameters:
key- The key of the transient property
-
setTransientProperty
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 propertyo- The value of the transient property
-
setTransientPropertyIfAbsent
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 propertyo- The value of the transient property
-
containsTransientProperty
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
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 atdata- The data to put
-
setIfAbsent
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 atdata- The data to put
-
setData
-
get
Gets the object mapped to a certain key- Parameters:
key- The key- Returns:
- The object mapped to the key
-
getInt
Gets an int mapped to a certain key- Parameters:
key- The key- Returns:
- The int mapped to the key
-
getString
Gets a String mapped to a certain key- Parameters:
key- The key- Returns:
- The String mapped to the key
-
getBoolean
Gets a boolean mapped to a certain key- Parameters:
key- The key- Returns:
- The boolean mapped to the key
-
getDouble
Gets a double mapped to a certain key- Parameters:
key- The key- Returns:
- The double mapped to the key
-
getLong
Gets a double mapped to a certain key- Parameters:
key- The key- Returns:
- The double mapped to the key
-
getMap
Gets a JSONMap mapped to a certain key- Parameters:
key- The key- Returns:
- The JSONMap mapped to the key
-
getList
Gets a JSONList mapped to a certain key- Parameters:
key- The key- Returns:
- The JSONList mapped to the key
-
remove
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
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
- 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
- Returns:
- The BlockDataManager managing this DataBlock
-
hashCode
public int hashCode() -
equals
-