Class LocationUtil

java.lang.Object
net.mathias2246.buildmc.util.LocationUtil

public final class LocationUtil extends Object
A Utility class for Bukkit Locations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    calculateChunkArea(int chunkX1, int chunkZ1, int chunkX2, int chunkZ2)
     
    static int
    calculateChunkArea(@NotNull org.bukkit.Location pos1, @NotNull org.bukkit.Location pos2)
    Calculates the number of chunks covered by the area defined by two positions.
    static @NotNull org.bukkit.Location
    Deserialize a String back into a Location.
    static String
    serialize(org.bukkit.Location location)
    Serialize a Location into a String.
    static @Nullable org.bukkit.Location
    Deserialize a String back into a Location.

    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

    • serialize

      public static String serialize(org.bukkit.Location location)
      Serialize a Location into a String. Format: world,x,y,z,yaw,pitch
      Parameters:
      location - the Location to serialize
      Returns:
      serialized String
    • deserialize

      @NotNull public static @NotNull org.bukkit.Location deserialize(String data)
      Deserialize a String back into a Location. Must match the format from serialize()
      Parameters:
      data - the serialized string
      Returns:
      Location object
    • tryDeserialize

      @Nullable public static @Nullable org.bukkit.Location tryDeserialize(String data)
      Deserialize a String back into a Location. Must match the format from serialize()
      Parameters:
      data - the serialized string
      Returns:
      Location object, or null is failed
    • calculateChunkArea

      public static int calculateChunkArea(@NotNull @NotNull org.bukkit.Location pos1, @NotNull @NotNull org.bukkit.Location pos2)
      Calculates the number of chunks covered by the area defined by two positions. Both positions must be in the same world.
      Parameters:
      pos1 - First corner location
      pos2 - Second corner location
      Returns:
      Number of chunks in the rectangular selection
    • calculateChunkArea

      public static int calculateChunkArea(int chunkX1, int chunkZ1, int chunkX2, int chunkZ2)