Package com.ranull.graves.util
Class LocationUtil
java.lang.Object
com.ranull.graves.util.LocationUtil
Utility class for handling location-related operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.Location
chunkStringToLocation
(String string) Converts a chunk string representation back to a Location object.static String
chunkToString
(org.bukkit.Location location) Converts a chunk's location to a string representation.static org.bukkit.Location
deserializeLocation
(String serializedLocation) Deserializes a location from a string format.static org.bukkit.Location
getClosestLocation
(org.bukkit.Location locationBase, List<org.bukkit.Location> locationList) Finds the closest location to a given base location from a list of locations.static String
locationToString
(org.bukkit.Location location) Converts a Location object to a string representation.static org.bukkit.Location
roundLocation
(org.bukkit.Location location) Rounds the given location's coordinates to the nearest whole numbers.static org.bukkit.Location
stringToLocation
(String string) Converts a string representation of a location back to a Location object.
-
Constructor Details
-
LocationUtil
public LocationUtil()
-
-
Method Details
-
roundLocation
public static org.bukkit.Location roundLocation(org.bukkit.Location location) Rounds the given location's coordinates to the nearest whole numbers.- Parameters:
location
- The location to be rounded.- Returns:
- A new location with rounded coordinates.
-
locationToString
Converts a Location object to a string representation.- Parameters:
location
- The location to be converted.- Returns:
- A string representation of the location in the format "world|x|y|z".
-
chunkToString
Converts a chunk's location to a string representation.- Parameters:
location
- The location within the chunk.- Returns:
- A string representation of the chunk in the format "world|chunkX|chunkZ".
-
chunkStringToLocation
Converts a chunk string representation back to a Location object.- Parameters:
string
- The string representation of the chunk in the format "world|chunkX|chunkZ".- Returns:
- A Location object representing the chunk.
-
stringToLocation
Converts a string representation of a location back to a Location object.- Parameters:
string
- The string representation of the location in the format "world|x|y|z".- Returns:
- A Location object.
-
getClosestLocation
public static org.bukkit.Location getClosestLocation(org.bukkit.Location locationBase, List<org.bukkit.Location> locationList) Finds the closest location to a given base location from a list of locations.- Parameters:
locationBase
- The base location to compare against.locationList
- The list of locations to search through.- Returns:
- The closest location to the base location, or null if the list is empty.
-
deserializeLocation
Deserializes a location from a string format. The expected format is "world,x,y,z,pitch,yaw".- Parameters:
serializedLocation
- The serialized location string.- Returns:
- The deserialized Location object, or null if the format is invalid.
-