Class Location

java.lang.Object
com.plotsquared.core.location.BlockLoc
com.plotsquared.core.location.Location
All Implemented Interfaces:
Comparable<Location>

public final class Location extends BlockLoc implements Comparable<Location>
An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
  • Field Summary

    Fields inherited from class com.plotsquared.core.location.BlockLoc

    MINY, ZERO
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull Location
    add​(int x, int y, int z)
    Return a new location offset by the given coordinates
    static @NonNull Location
    at​(@NonNull World<?> world, int x, int y, int z)
    Construct a new location with yaw and pitch equal to 0
    static @NonNull Location
    at​(@NonNull World<?> world, int x, int y, int z, float yaw, float pitch)
    Construct a new location
    static @NonNull Location
    at​(@NonNull World<?> world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3)
    Construct a new location with yaw and pitch equal to 0
    static @NonNull Location
    at​(@NonNull World<?> world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3, float yaw, float pitch)
    Construct a new location
    static @NonNull Location
    at​(@NonNull String world, int x, int y, int z)
    Construct a new location with yaw and pitch equal to 0
    static @NonNull Location
    at​(@NonNull String world, int x, int y, int z, float yaw, float pitch)
    Construct a new location
    static @NonNull Location
    at​(@NonNull String world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3)
    Construct a new location with yaw and pitch equal to 0
    static @NonNull Location
    at​(@NonNull String world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3, float yaw, float pitch)
    Construct a new location
    int
    compareTo​(@NonNull Location o)
     
    boolean
    equals​(Object o)
     
    com.sk89q.worldedit.math.BlockVector3
     
    @NonNull com.sk89q.worldedit.math.BlockVector2
    Get the coordinates of the chunk that contains this location
    double
     
    double
     
    @Nullable Plot
    Get the owned Plot, if any, that contains this location
    @Nullable Plot
    Get the (absolute) owned Plot, if any, that contains this location
    float
     
    @Nullable Plot
    Get the Plot, if any, that contains this location
    @Nullable Plot
    Get the absolute Plot, if any, that contains this location
    @Nullable PlotArea
    Get the PlotArea, if any, that contains this location
    @NonNull World<?>
    Get the world object
    @NonNull String
    Get the name of the world this location is in
    int
    Get the X coordinate
    int
    Get the Y coordinate
    float
     
    int
    Get the Z coordinate
    int
     
    boolean
    Check whether the location belongs to a plot area
    boolean
    Check whether the location belongs to a plot road
    boolean
    Checks if anyone owns a plot at the current location.
    @NonNull Location
    subtract​(int x, int y, int z)
    Return a new location offset by (-) the given coordinates
    @NonNull org.khelekore.prtree.MBR
    Get a minimum bounding rectangle that contains this location only
     
    @NonNull Location
    withPitch​(float pitch)
    Return a new location using the given pitch
    @NonNull Location
    withWorld​(@NonNull String world)
    Return a new location using the given world
    @NonNull Location
    withX​(int x)
    Return a new location using the given X coordinate
    @NonNull Location
    withY​(int y)
    Return a new location using the given Y coordinate
    @NonNull Location
    withYaw​(float yaw)
    Return a new location using the given yaw
    @NonNull Location
    withZ​(int z)
    Return a new location using the given Z coordinate

    Methods inherited from class com.plotsquared.core.location.BlockLoc

    fromString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • at

      public static @NonNull Location at(@NonNull String world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3, float yaw, float pitch)
      Construct a new location
      Parameters:
      world - World
      blockVector3 - (x,y,z) vector
      yaw - yaw
      pitch - pitch
      Returns:
      New location
    • at

      public static @NonNull Location at(@NonNull String world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3)
      Construct a new location with yaw and pitch equal to 0
      Parameters:
      world - World
      blockVector3 - (x,y,z) vector
      Returns:
      New location
    • at

      public static @NonNull Location at(@NonNull String world, int x, int y, int z, float yaw, float pitch)
      Construct a new location
      Parameters:
      world - World
      x - X coordinate
      y - Y coordinate
      z - Z coordinate
      yaw - Yaw
      pitch - Pitch
      Returns:
      New location
    • at

      public static @NonNull Location at(@NonNull String world, int x, int y, int z)
      Construct a new location with yaw and pitch equal to 0
      Parameters:
      world - World
      x - X coordinate
      y - Y coordinate
      z - Z coordinate
      Returns:
      New location
    • at

      public static @NonNull Location at(@NonNull World<?> world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3, float yaw, float pitch)
      Construct a new location
      Parameters:
      world - World
      blockVector3 - (x,y,z) vector
      yaw - yaw
      pitch - pitch
      Returns:
      New location
    • at

      public static @NonNull Location at(@NonNull World<?> world, @NonNull com.sk89q.worldedit.math.BlockVector3 blockVector3)
      Construct a new location with yaw and pitch equal to 0
      Parameters:
      world - World
      blockVector3 - (x,y,z) vector
      Returns:
      New location
    • at

      public static @NonNull Location at(@NonNull World<?> world, int x, int y, int z, float yaw, float pitch)
      Construct a new location
      Parameters:
      world - World
      x - X coordinate
      y - Y coordinate
      z - Z coordinate
      yaw - Yaw
      pitch - Pitch
      Returns:
      New location
    • at

      public static @NonNull Location at(@NonNull World<?> world, int x, int y, int z)
      Construct a new location with yaw and pitch equal to 0
      Parameters:
      world - World
      x - X coordinate
      y - Y coordinate
      z - Z coordinate
      Returns:
      New location
    • getWorld

      public @NonNull World<?> getWorld()
      Get the world object
      Returns:
      World object
    • getWorldName

      public @NonNull String getWorldName()
      Get the name of the world this location is in
      Returns:
      World name
    • getX

      public int getX()
      Get the X coordinate
      Overrides:
      getX in class BlockLoc
      Returns:
      X coordinate
    • getY

      public int getY()
      Get the Y coordinate
      Overrides:
      getY in class BlockLoc
      Returns:
      Y coordinate
    • getZ

      public int getZ()
      Get the Z coordinate
      Overrides:
      getZ in class BlockLoc
      Returns:
      Z coordinate
    • getPlotArea

      public @Nullable PlotArea getPlotArea()
      Get the PlotArea, if any, that contains this location
      Returns:
      Plot area containing the location, or null
    • getOwnedPlot

      public @Nullable Plot getOwnedPlot()
      Get the owned Plot, if any, that contains this location
      Returns:
      Plot containing the location, or null
    • getOwnedPlotAbs

      public @Nullable Plot getOwnedPlotAbs()
      Get the (absolute) owned Plot, if any, that contains this location
      Returns:
      (Absolute) plot containing the location, or null
    • isPlotArea

      public boolean isPlotArea()
      Check whether the location belongs to a plot area
      Returns:
      true if the location belongs to a plot area, else false
    • isPlotRoad

      public boolean isPlotRoad()
      Check whether the location belongs to a plot road
      Returns:
      true if the location belongs to a plot road, else false
    • isUnownedPlotArea

      public boolean isUnownedPlotArea()
      Checks if anyone owns a plot at the current location.
      Returns:
      true if the location is a road, not a plot area, or if the plot is unclaimed.
    • getPlotAbs

      public @Nullable Plot getPlotAbs()
      Get the absolute Plot, if any, that contains this location
      Returns:
      (Absolute) plot containing the location, or {code null}
    • getPlot

      public @Nullable Plot getPlot()
      Get the Plot, if any, that contains this location
      Returns:
      plot containing the location, or {code null}
    • getChunkLocation

      public @NonNull com.sk89q.worldedit.math.BlockVector2 getChunkLocation()
      Get the coordinates of the chunk that contains this location
      Returns:
      Chunk coordinates
    • add

      public @NonNull Location add(int x, int y, int z)
      Return a new location offset by the given coordinates
      Parameters:
      x - X offset
      y - Y offset
      z - Z offset
      Returns:
      New location
    • withX

      public @NonNull Location withX(int x)
      Return a new location using the given X coordinate
      Parameters:
      x - New X coordinate
      Returns:
      New location
    • withY

      public @NonNull Location withY(int y)
      Return a new location using the given Y coordinate
      Parameters:
      y - New Y coordinate
      Returns:
      New location
    • withZ

      public @NonNull Location withZ(int z)
      Return a new location using the given Z coordinate
      Parameters:
      z - New Z coordinate
      Returns:
      New location
    • withYaw

      public @NonNull Location withYaw(float yaw)
      Return a new location using the given yaw
      Parameters:
      yaw - New yaw
      Returns:
      New location
    • withPitch

      public @NonNull Location withPitch(float pitch)
      Return a new location using the given pitch
      Parameters:
      pitch - New pitch
      Returns:
      New location
    • withWorld

      public @NonNull Location withWorld(@NonNull String world)
      Return a new location using the given world
      Parameters:
      world - New world
      Returns:
      New location
    • getEuclideanDistanceSquared

      public double getEuclideanDistanceSquared(@NonNull Location l2)
    • getEuclideanDistance

      public double getEuclideanDistance(@NonNull Location l2)
    • subtract

      public @NonNull Location subtract(int x, int y, int z)
      Return a new location offset by (-) the given coordinates
      Parameters:
      x - X offset
      y - Y offset
      z - Z offset
      Returns:
      New location
    • toMBR

      public @NonNull org.khelekore.prtree.MBR toMBR()
      Get a minimum bounding rectangle that contains this location only
      Returns:
      Minimum bounding rectangle
    • compareTo

      public int compareTo(@NonNull Location o)
      Specified by:
      compareTo in interface Comparable<Location>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class BlockLoc
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BlockLoc
    • toString

      public String toString()
      Overrides:
      toString in class BlockLoc
    • getYaw

      public float getYaw()
      Overrides:
      getYaw in class BlockLoc
    • getPitch

      public float getPitch()
      Overrides:
      getPitch in class BlockLoc
    • getBlockVector3

      public com.sk89q.worldedit.math.BlockVector3 getBlockVector3()