Package de.marcely.bedwars.tools
Interface PersistentBlockData
public interface PersistentBlockData
This class allows you to obtain, store and restore a blocks data.
This class is pretty similar to todays Bukkit's BlockData API. The reason this exists is to add the same or similar functionality to older versions of spigot, as they don't have that functionality.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PersistentBlockData
Fetches all the data from the block and constructs a new instance from thatstatic PersistentBlockData
fromMaterial
(Material mat) Constructs a new instance given by a materialTransforms the data into a string which later can be reloaded withparse(String)
.getDyedData
(DyeColor color) Tries to dye this block and possibly returns a new instance with the blocked dyed in the given color.Returns the material of the block.boolean
matches
(PersistentBlockData data) Returns if the given instance is similar to this one.boolean
Returns whether the stored data matches the current data of the given block.static @Nullable PersistentBlockData
Tries to parse a previously encoded string usinggetAsString()
.default void
Places the data for a block at a specific location with applying phyics.void
Places the data for a block at a specific location.
-
Method Details
-
getMaterial
Material getMaterial()Returns the material of the block.- Returns:
- The material of the block
-
place
Places the data for a block at a specific location with applying phyics.- Parameters:
block
- The block that shall be replaced with this data
-
place
Places the data for a block at a specific location.- Parameters:
block
- The block that shall be replaced with this dataapplyPhysics
- Doesn't calculate physics for this and surrounding blocks. May safe performance
-
getAsString
String getAsString()Transforms the data into a string which later can be reloaded withparse(String)
.Keep in mind that it's likely possible that you want be able to load a parsed string in 1.8 - 1.12 within 1.13+ and vice versa.
- Returns:
- A string representing all daa stored in this instance
-
matches
Returns if the given instance is similar to this one.- Parameters:
data
- The other instance we want to compare with- Returns:
true
when they match
-
matches
Returns whether the stored data matches the current data of the given block.- Parameters:
block
- The block that we want to match- Returns:
true
when they are basically the same
-
getDyedData
Tries to dye this block and possibly returns a new instance with the blocked dyed in the given color.- Parameters:
color
- The new color we want it to have- Returns:
- A new instance with the new color, or this one
-
parse
Tries to parse a previously encoded string usinggetAsString()
.Keep in mind that it's likely possible that you want be able to load a parsed string in 1.8 - 1.12 within 1.13+ and vice versa.
- Parameters:
str
- The string we want to parse- Returns:
- The parsed instance.
null
if it failed
-
fromBlock
Fetches all the data from the block and constructs a new instance from that- Parameters:
block
- The block we want to read from- Returns:
- The instance representing the data of the block at this given moment
-
fromMaterial
Constructs a new instance given by a material- Parameters:
mat
- The material- Returns:
- A new instance with only the given material at its containing data
-