Class SeBlock
java.lang.Object
me.tayebyassine.homestead.models.serialize.SeBlock
Serializable representation of a block position.
Stores the world UUID and block coordinates so the position can be
persisted as a comma-separated string and later deserialized back into
a Bukkit Block.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a serializable block position from a world UUID and coordinates.SeBlock(org.bukkit.block.Block block) Create a serializable block position from a Bukkit block.SeBlock(org.bukkit.World world, int x, int y, int z) Create a serializable block position from a world and coordinates. -
Method Summary
Modifier and TypeMethodDescriptionstatic SeBlockdeserialize(@NotNull String serialized) Deserialize a block position from its comma-separated string form.booleanorg.bukkit.WorldgetWorld()Get the Bukkit world.Get the world UUID.intgetX()Get the x coordinate.intgetY()Get the y coordinate.intgetZ()Get the z coordinate.inthashCode()Serialise the block position to a comma-separated string.voidsetWorld(org.bukkit.World world) Set the world from a Bukkit world reference.voidsetWorldId(UUID worldId) Set the world UUID.voidsetX(int x) Set the x coordinate.voidsetY(int y) Set the y coordinate.voidsetZ(int z) Set the z coordinate.org.bukkit.block.BlocktoBukkit()Convert this position to a Bukkit block.toString()
-
Constructor Details
-
SeBlock
public SeBlock(org.bukkit.block.Block block) Create a serializable block position from a Bukkit block.- Parameters:
block- the block to copy coordinates from
-
SeBlock
public SeBlock(org.bukkit.World world, int x, int y, int z) Create a serializable block position from a world and coordinates.- Parameters:
world- the worldx- the x coordinatey- the y coordinatez- the z coordinate
-
SeBlock
Create a serializable block position from a world UUID and coordinates.- Parameters:
worldId- the world UUIDx- the x coordinatey- the y coordinatez- the z coordinate
-
-
Method Details
-
deserialize
Deserialize a block position from its comma-separated string form.- Parameters:
serialized- the string in the formatworldId,x,y,z- Returns:
- the deserialized block position, or
nullif the world no longer exists - Throws:
IllegalArgumentException- if the format is invalid
-
getWorldId
-
setWorldId
-
getWorld
public org.bukkit.World getWorld()Get the Bukkit world.- Returns:
- the world, or
nullif it no longer exists
-
setWorld
public void setWorld(org.bukkit.World world) Set the world from a Bukkit world reference.- Parameters:
world- the world
-
getX
public int getX()Get the x coordinate.- Returns:
- the x coordinate
-
setX
public void setX(int x) Set the x coordinate.- Parameters:
x- the new x coordinate
-
getY
public int getY()Get the y coordinate.- Returns:
- the y coordinate
-
setY
public void setY(int y) Set the y coordinate.- Parameters:
y- the new y coordinate
-
getZ
public int getZ()Get the z coordinate.- Returns:
- the z coordinate
-
setZ
public void setZ(int z) Set the z coordinate.- Parameters:
z- the new z coordinate
-
serialize
Serialise the block position to a comma-separated string.- Returns:
- the encoded string in the format
worldId,x,y,z
-
toBukkit
public org.bukkit.block.Block toBukkit()Convert this position to a Bukkit block.- Returns:
- the block at this position, or
nullif the world no longer exists
-
toString
-
equals
-
hashCode
-