Class SeBlock

java.lang.Object
me.tayebyassine.homestead.models.serialize.SeBlock

public final class SeBlock extends Object
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

    Constructors
    Constructor
    Description
    SeBlock(UUID worldId, int x, int y, int z)
    Create 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 Type
    Method
    Description
    static SeBlock
    deserialize(@NotNull String serialized)
    Deserialize a block position from its comma-separated string form.
    boolean
     
    org.bukkit.World
    Get the Bukkit world.
    Get the world UUID.
    int
    Get the x coordinate.
    int
    Get the y coordinate.
    int
    Get the z coordinate.
    int
     
    Serialise the block position to a comma-separated string.
    void
    setWorld(org.bukkit.World world)
    Set the world from a Bukkit world reference.
    void
    setWorldId(UUID worldId)
    Set the world UUID.
    void
    setX(int x)
    Set the x coordinate.
    void
    setY(int y)
    Set the y coordinate.
    void
    setZ(int z)
    Set the z coordinate.
    org.bukkit.block.Block
    Convert this position to a Bukkit block.
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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 world
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
    • SeBlock

      public SeBlock(UUID worldId, int x, int y, int z)
      Create a serializable block position from a world UUID and coordinates.
      Parameters:
      worldId - the world UUID
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
  • Method Details

    • deserialize

      public static SeBlock deserialize(@NotNull @NotNull String serialized)
      Deserialize a block position from its comma-separated string form.
      Parameters:
      serialized - the string in the format worldId,x,y,z
      Returns:
      the deserialized block position, or null if the world no longer exists
      Throws:
      IllegalArgumentException - if the format is invalid
    • getWorldId

      public UUID getWorldId()
      Get the world UUID.
      Returns:
      the world UUID
    • setWorldId

      public void setWorldId(UUID worldId)
      Set the world UUID.
      Parameters:
      worldId - the new world UUID
    • getWorld

      public org.bukkit.World getWorld()
      Get the Bukkit world.
      Returns:
      the world, or null if 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

      public String 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 null if the world no longer exists
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object