Class LocationUtils

java.lang.Object
com.marcusslover.plus.lib.world.LocationUtils

public class LocationUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.Location
    centerLocation(org.bukkit.Location location)
    This will modify the passed in location to be at the center of the block.
    static org.bukkit.Location
    Converts a String back to a Location.
    static org.bukkit.Location
    fromAccurateString(String string, String separator)
    Converts a String back to a Location
    static org.bukkit.Location
    Converts a String back to a Location.
    static org.bukkit.Location
    fromString(String string, String separator)
    Converts a String back to a Location
    static void
    fromStringLater(String string, String separator, Consumer<org.bukkit.Location> callback)
    Loads a Location from a String.
    static void
    fromStringLater(String string, Consumer<org.bukkit.Location> callback)
    Loads a Location from a String.
    static double
    This will +/- 0.5 of an exact cord to get the center of the block
    static int[]
    getChunkCoordinates(org.bukkit.Location loc)
    Gets the chunk X and Z of a location
    protected @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.Vector
    getDirection(org.bukkit.block.BlockFace face)
    Gets the Vector direction of a BlockFace.
    static String
    toAccurateString(String world, double x, double y, double z, float yaw, float pitch, String separator)
    Converts a Location to a precise String
    static String
    toAccurateString(org.bukkit.Location loc, String separator)
    Converts a Location to a precise String
    static String
    toString(org.bukkit.block.Block block)
    Converts a Location to a String representing its location
    static String
    toString(org.bukkit.block.Block block, String separator)
    Converts a Location to a String representing its location
    static String
    toString(org.bukkit.Location loc)
    Converts a Location to a String.
    static String
    toString(org.bukkit.Location loc, String separator)
    Converts a Location to a String
    static void
    waitForWorld(String worldname, Consumer<org.bukkit.World> callback)
    Waits for a world with the given name to load before calling the callback

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 Location
      separator - The separator used when converting this Location to a String
      callback - The callback to use the Location once it has been loaded
    • fromString

      public static org.bukkit.Location fromString(String string, String separator)
      Converts a String back to a Location
      Parameters:
      string - The stringified Location
      separator - The separator that was used in toString
      Returns:
      The Location
    • fromString

      public static org.bukkit.Location fromString(String string)
      Converts a String back to a Location. The same as calling fromString(String, " ")
      Parameters:
      string - The stringified Location
      Returns:
      The Location
    • fromAccurateString

      public static org.bukkit.Location fromAccurateString(String string, String separator)
      Converts a String back to a Location
      Parameters:
      string - The stringified Location
      separator - The separator that was used in toString
      Returns:
      The Location
    • fromAccurateString

      public static org.bukkit.Location fromAccurateString(String string)
      Converts a String back to a Location. The same as calling fromString(String, " ")
      Parameters:
      string - The stringified Location
      Returns:
      The Location
    • toAccurateString

      public static String toAccurateString(org.bukkit.Location loc, String separator)
      Converts a Location to a precise String
      Parameters:
      loc - The Location to be stringified
      separator - 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

      public static String toString(org.bukkit.Location loc, String separator)
      Converts a Location to a String
      Parameters:
      loc - The Location to be stringified
      separator - The separator to use between pieces of information
      Returns:
      The stringified Location
    • toString

      public static String toString(org.bukkit.block.Block block, String separator)
      Converts a Location to a String representing its location
      Parameters:
      block - The Block location to be stringified
      separator - The separator to use between pieces of information
      Returns:
      The stringified location
    • toString

      public static String toString(org.bukkit.block.Block block)
      Converts a Location to a String representing its location
      Parameters:
      block - The Block location to be stringified
      Returns:
      The stringified location
    • fromStringLater

      public static void fromStringLater(String string, 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 Location
      callback - The callback to use the Location once it has been loaded
    • toString

      public static String toString(org.bukkit.Location loc)
      Converts a Location to a String. The same as calling toString(Location, " ")
      Parameters:
      loc - The Location to be stringified
      Returns:
      The stringified Location
    • waitForWorld

      public static void waitForWorld(String worldname, Consumer<org.bukkit.World> callback)
      Waits for a world with the given name to load before calling the callback
      Parameters:
      worldname - The name of the world
      callback - 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.