Class LocationUtil
java.lang.Object
net.mathias2246.buildmc.util.LocationUtil
A Utility class for Bukkit Locations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalculateChunkArea(int chunkX1, int chunkZ1, int chunkX2, int chunkZ2) Calculates the Area in chunks between these chunk coordinates.static intcalculateChunkArea(@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.Locationdeserialize(String data) Deserialize a String back into a Location.static org.bukkit.util.Vector[]getBlockCorners(Claim claim) Returns the min and max block coordinates of a claim.static Stringserialize(org.bukkit.Location location) Serialize a Location into a String.static @Nullable org.bukkit.LocationtryDeserialize(String data) Deserialize a String back into a Location.
-
Constructor Details
-
LocationUtil
public LocationUtil()
-
-
Method Details
-
serialize
Serialize a Location into a String. Format: world,x,y,z,yaw,pitch- Parameters:
location- the Location to serialize- Returns:
- serialized String
-
deserialize
@Contract(value="null -> fail; _ -> new;", pure=true) @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
@Contract(value="_ -> _", pure=true) @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
@Contract(pure=true) 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 locationpos2- Second corner location- Returns:
- Number of chunks in the rectangular selection
-
calculateChunkArea
@Contract(pure=true) public static int calculateChunkArea(int chunkX1, int chunkZ1, int chunkX2, int chunkZ2) Calculates the Area in chunks between these chunk coordinates.- Parameters:
chunkX1- the smallest chunk X coordinatechunkZ1- the smallest chunk Z coordinatechunkX2- the largest chunk X coordinatechunkZ2- the largest chunk Z coordinate- Returns:
- The Area in chunks
-
getBlockCorners
Returns the min and max block coordinates of a claim. Always sorted: x1 <= x2, z1 <= z2- Parameters:
claim- The claim- Returns:
- Vector array: [minCorner, maxCorner]
-