Class SeLocation
java.lang.Object
me.tayebyassine.homestead.models.serialize.SeLocation
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
ConstructorsConstructorDescriptionSeLocation(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 TypeMethodDescriptionstatic SeLocationdeserialize(@NotNull String serialized) Deserialize a location from its comma-separated string form.booleanfloatgetPitch()Get the pitch rotation.org.bukkit.WorldgetWorld()Get the Bukkit world.Get the world UUID.doublegetX()Get the x coordinate.doublegetY()Get the y coordinate.floatgetYaw()Get the yaw rotation.doublegetZ()Get the z coordinate.inthashCode()Serialise the location to a comma-separated string.voidsetPitch(float pitch) Set the pitch rotation.voidsetWorld(org.bukkit.World world) Set the world from a Bukkit world reference.voidsetWorldId(UUID worldId) Set the world UUID.voidsetX(double x) Set the x coordinate.voidsetY(double y) Set the y coordinate.voidsetYaw(float yaw) Set the yaw rotation.voidsetZ(double z) Set the z coordinate.org.bukkit.LocationtoBukkit()Convert this serializable location to a Bukkit location.toString()
-
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 worldx- the x coordinatey- the y coordinatez- the z coordinateyaw- the yaw rotationpitch- the pitch rotation
-
SeLocation
Create a serializable location from a world UUID and coordinates.- Parameters:
worldId- the world UUIDx- the x coordinatey- the y coordinatez- the z coordinateyaw- the yaw rotationpitch- the pitch rotation
-
-
Method Details
-
deserialize
Deserialize a location from its comma-separated string form.- Parameters:
serialized- the string in the formatworldId,x,y,z,yaw,pitch- Returns:
- the deserialized location, 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 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
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
nullif the world no longer exists
-
toString
-
equals
-
hashCode
-