Class LocationUtil

java.lang.Object
com.ranull.graves.util.LocationUtil

public final class LocationUtil extends Object
Utility class for handling location-related operations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.Location
    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
    Converts a string representation of a location back to a Location object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static String locationToString(org.bukkit.Location location)
      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

      public static String chunkToString(org.bukkit.Location location)
      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

      public static org.bukkit.Location chunkStringToLocation(String string)
      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

      public static org.bukkit.Location stringToLocation(String string)
      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

      public static org.bukkit.Location deserializeLocation(String serializedLocation)
      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.