Package com.marcusslover.plus.lib.world
Class LocationUtils
java.lang.Object
com.marcusslover.plus.lib.world.LocationUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.LocationcenterLocation(org.bukkit.Location location) This will modify the passed in location to be at the center of the block.static org.bukkit.LocationfromAccurateString(String string) Converts a String back to a Location.static org.bukkit.LocationfromAccurateString(String string, String separator) Converts a String back to a Locationstatic org.bukkit.LocationfromString(String string) Converts a String back to a Location.static org.bukkit.LocationfromString(String string, String separator) Converts a String back to a Locationstatic voidfromStringLater(String string, String separator, Consumer<org.bukkit.Location> callback) Loads a Location from a String.static voidfromStringLater(String string, Consumer<org.bukkit.Location> callback) Loads a Location from a String.static doublegetCenterCord(int i) This will +/- 0.5 of an exact cord to get the center of the blockstatic int[]getChunkCoordinates(org.bukkit.Location loc) Gets the chunk X and Z of a locationprotected @NotNull List<org.bukkit.Location> getCircle(@NotNull org.bukkit.Location center, double radius, int amount) Returns a list of locations that are in a circle around the given center.static org.bukkit.util.VectorgetDirection(org.bukkit.block.BlockFace face) Gets the Vector direction of a BlockFace.static StringtoAccurateString(String world, double x, double y, double z, float yaw, float pitch, String separator) Converts a Location to a precise Stringstatic StringtoAccurateString(org.bukkit.Location loc, String separator) Converts a Location to a precise Stringstatic StringtoString(org.bukkit.block.Block block) Converts a Location to a String representing its locationstatic StringConverts a Location to a String representing its locationstatic StringtoString(org.bukkit.Location loc) Converts a Location to a String.static StringConverts a Location to a Stringstatic voidwaitForWorld(String worldname, Consumer<org.bukkit.World> callback) Waits for a world with the given name to load before calling the callback
-
Constructor Details
-
LocationUtils
public LocationUtils()
-
-
Method Details
-
getChunkCoordinates
public static int[] getChunkCoordinates(org.bukkit.Location loc) Gets the chunk X and Z of a location- Parameters:
loc- The location to get the chunk coordinates of- Returns:
- An array containing the chunk coordinates [x, z]
-
fromStringLater
public static void fromStringLater(String string, String separator, Consumer<org.bukkit.Location> callback) Loads a Location from a String. If the world this Location is in is not yet loaded, waits for it to load, then passes the Location to the callback.- Parameters:
string- The String to be parsed into a Locationseparator- The separator used when converting this Location to a Stringcallback- The callback to use the Location once it has been loaded
-
fromString
Converts a String back to a Location- Parameters:
string- The stringified Locationseparator- The separator that was used in toString- Returns:
- The Location
-
fromString
Converts a String back to a Location. The same as calling fromString(String, " ")- Parameters:
string- The stringified Location- Returns:
- The Location
-
fromAccurateString
Converts a String back to a Location- Parameters:
string- The stringified Locationseparator- The separator that was used in toString- Returns:
- The Location
-
fromAccurateString
Converts a String back to a Location. The same as calling fromString(String, " ")- Parameters:
string- The stringified Location- Returns:
- The Location
-
toAccurateString
Converts a Location to a precise String- Parameters:
loc- The Location to be stringifiedseparator- The separator to use between pieces of information- Returns:
- The stringified Location
-
toAccurateString
public static String toAccurateString(String world, double x, double y, double z, float yaw, float pitch, String separator) Converts a Location to a precise String- Parameters:
separator- The separator to use between pieces of information- Returns:
- The stringified Location
-
toString
Converts a Location to a String- Parameters:
loc- The Location to be stringifiedseparator- The separator to use between pieces of information- Returns:
- The stringified Location
-
toString
Converts a Location to a String representing its location- Parameters:
block- The Block location to be stringifiedseparator- The separator to use between pieces of information- Returns:
- The stringified location
-
toString
Converts a Location to a String representing its location- Parameters:
block- The Block location to be stringified- Returns:
- The stringified location
-
fromStringLater
Loads a Location from a String. If the world this Location is in is not yet loaded, waits for it to load, then passes the Location to the callback.- Parameters:
string- The String to be parsed into a Locationcallback- The callback to use the Location once it has been loaded
-
toString
Converts a Location to a String. The same as calling toString(Location, " ")- Parameters:
loc- The Location to be stringified- Returns:
- The stringified Location
-
waitForWorld
Waits for a world with the given name to load before calling the callback- Parameters:
worldname- The name of the worldcallback- A callback to be passed the world when it loads
-
getCenterCord
public static double getCenterCord(int i) This will +/- 0.5 of an exact cord to get the center of the block -
getDirection
public static org.bukkit.util.Vector getDirection(org.bukkit.block.BlockFace face) Gets the Vector direction of a BlockFace. For use in versions below 1.13.- Parameters:
face- The block face- Returns:
- The vector representing the direction
-
centerLocation
public org.bukkit.Location centerLocation(org.bukkit.Location location) This will modify the passed in location to be at the center of the block. -
getCircle
@NotNull protected @NotNull List<org.bukkit.Location> getCircle(@NotNull @NotNull org.bukkit.Location center, double radius, int amount) Returns a list of locations that are in a circle around the given center.
-