Class SeLocation

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

public final class SeLocation extends Object
Serializable representation of a location with full precision.

Stores the world UUID, double-precision coordinates, and yaw/pitch so the location can be persisted as a comma-separated string and later deserialized back into a Bukkit Location.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SeLocation(UUID worldId, double x, double y, double z, float yaw, float pitch)
    Create a serializable location from a world UUID and coordinates.
    SeLocation(org.bukkit.Location location)
    Create a serializable location from a Bukkit location.
    SeLocation(org.bukkit.World world, double x, double y, double z, float yaw, float pitch)
    Create a serializable location from a world and coordinates.
  • Method Summary

    Modifier and Type
    Method
    Description
    static SeLocation
    deserialize(@NotNull String serialized)
    Deserialize a location from its comma-separated string form.
    boolean
     
    float
    Get the pitch rotation.
    org.bukkit.World
    Get the Bukkit world.
    Get the world UUID.
    double
    Get the x coordinate.
    double
    Get the y coordinate.
    float
    Get the yaw rotation.
    double
    Get the z coordinate.
    int
     
    Serialise the location to a comma-separated string.
    void
    setPitch(float pitch)
    Set the pitch rotation.
    void
    setWorld(org.bukkit.World world)
    Set the world from a Bukkit world reference.
    void
    setWorldId(UUID worldId)
    Set the world UUID.
    void
    setX(double x)
    Set the x coordinate.
    void
    setY(double y)
    Set the y coordinate.
    void
    setYaw(float yaw)
    Set the yaw rotation.
    void
    setZ(double z)
    Set the z coordinate.
    org.bukkit.Location
    Convert this serializable location to a Bukkit location.
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SeLocation

      public SeLocation(org.bukkit.Location location)
      Create a serializable location from a Bukkit location.
      Parameters:
      location - the location to copy from
    • SeLocation

      public SeLocation(org.bukkit.World world, double x, double y, double z, float yaw, float pitch)
      Create a serializable location from a world and coordinates.
      Parameters:
      world - the world
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      yaw - the yaw rotation
      pitch - the pitch rotation
    • SeLocation

      public SeLocation(UUID worldId, double x, double y, double z, float yaw, float pitch)
      Create a serializable location from a world UUID and coordinates.
      Parameters:
      worldId - the world UUID
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      yaw - the yaw rotation
      pitch - the pitch rotation
  • Method Details

    • deserialize

      public static SeLocation deserialize(@NotNull @NotNull String serialized)
      Deserialize a location from its comma-separated string form.
      Parameters:
      serialized - the string in the format worldId,x,y,z,yaw,pitch
      Returns:
      the deserialized location, 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 double getX()
      Get the x coordinate.
      Returns:
      the x coordinate
    • setX

      public void setX(double x)
      Set the x coordinate.
      Parameters:
      x - the new x coordinate
    • getY

      public double getY()
      Get the y coordinate.
      Returns:
      the y coordinate
    • setY

      public void setY(double y)
      Set the y coordinate.
      Parameters:
      y - the new y coordinate
    • getZ

      public double getZ()
      Get the z coordinate.
      Returns:
      the z coordinate
    • setZ

      public void setZ(double z)
      Set the z coordinate.
      Parameters:
      z - the new z coordinate
    • getYaw

      public float getYaw()
      Get the yaw rotation.
      Returns:
      the yaw in degrees
    • setYaw

      public void setYaw(float yaw)
      Set the yaw rotation.
      Parameters:
      yaw - the new yaw in degrees
    • getPitch

      public float getPitch()
      Get the pitch rotation.
      Returns:
      the pitch in degrees
    • setPitch

      public void setPitch(float pitch)
      Set the pitch rotation.
      Parameters:
      pitch - the new pitch in degrees
    • serialize

      public String serialize()
      Serialise the location to a comma-separated string.
      Returns:
      the encoded string in the format worldId,x,y,z,yaw,pitch
    • toBukkit

      public org.bukkit.Location toBukkit()
      Convert this serializable location to a Bukkit location.
      Returns:
      the Bukkit location, 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