Class LocationManager

java.lang.Object
com.ranull.graves.manager.LocationManager

public final class LocationManager extends Object
Manages location-related operations for graves.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Graves
    The main plugin instance associated with Graves.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a new instance of the LocationManager class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canBuild(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, List<String> permissionList)
    Determines if a living entity can build at a specified location.
    private org.bukkit.Location
    findGround(org.bukkit.Location location)
    Finds the nearest solid ground below the given location.
    private org.bukkit.Location
    findLocationDownFromY(org.bukkit.Location location, org.bukkit.entity.Entity entity, int y, Grave grave)
    Attempts to find a safe grave location by searching downward from a specified Y-coordinate.
    private org.bukkit.Location
    findLocationUpFromY(org.bukkit.Location location, org.bukkit.entity.Entity entity, int y, Grave grave)
    Attempts to find a safe grave location by searching upward from a specified Y-coordinate.
    org.bukkit.Location
    getGround(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
    Gets the ground location for placement.
    org.bukkit.Location
    getLastSolidLocation(org.bukkit.entity.Entity entity)
    Gets the last solid location of an entity.
    org.bukkit.Location
    getLavaTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
    Gets the top location above lava for placement.
    int
    getMinHeight(org.bukkit.Location location)
    Gets the minimum height for a location.
    org.bukkit.Location
    getRoof(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
    Gets the roof location for placement.
    org.bukkit.Location
    getSafeGraveLocation(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, Grave grave)
    Gets a safe grave location.
    org.bukkit.Location
    getSafeTeleportLocation(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave, Graves plugin)
    Gets a safe teleport location.
    org.bukkit.Location
    getTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
    Finds the top location for placement, searching downward from the given location's Y-coordinate.
    org.bukkit.Location
    getVoid(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
    Gets the void location for placement.
    org.bukkit.Location
    getWaterTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
    Gets the top location above water for placement.
    boolean
    hasGrave(org.bukkit.Location location)
    Determines if a location has a grave.
    boolean
    isInsideBorder(org.bukkit.Location location)
    Determines if a location is inside the world border.
    boolean
    isLocationSafeGrave(org.bukkit.Location location)
    Determines if a location is safe for a grave.
    boolean
    isLocationSafePlayer(org.bukkit.Location location)
    Determines if a location is safe for a player to spawn or teleport to.
    boolean
    isVoid(org.bukkit.Location location)
    Determines if the specified location is in the void.
    void
    removeLastSolidLocation(org.bukkit.entity.Entity entity)
    Removes the last solid location of an entity.
    void
    setLastSolidLocation(org.bukkit.entity.Entity entity, org.bukkit.Location location)
    Sets the last solid location of an entity.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • plugin

      private final Graves plugin
      The main plugin instance associated with Graves.

      This Graves instance represents the core plugin that this Graves is part of. It provides access to the plugin's functionality, configuration, and other services.

  • Constructor Details

    • LocationManager

      public LocationManager(Graves plugin)
      Initializes a new instance of the LocationManager class.
      Parameters:
      plugin - The plugin instance.
  • Method Details

    • setLastSolidLocation

      public void setLastSolidLocation(org.bukkit.entity.Entity entity, org.bukkit.Location location)
      Sets the last solid location of an entity.
      Parameters:
      entity - The entity.
      location - The location.
    • getLastSolidLocation

      public org.bukkit.Location getLastSolidLocation(org.bukkit.entity.Entity entity)
      Gets the last solid location of an entity.
      Parameters:
      entity - The entity.
      Returns:
      The last solid location.
    • removeLastSolidLocation

      public void removeLastSolidLocation(org.bukkit.entity.Entity entity)
      Removes the last solid location of an entity.
      Parameters:
      entity - The entity.
    • getSafeTeleportLocation

      public org.bukkit.Location getSafeTeleportLocation(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave, Graves plugin)
      Gets a safe teleport location.
      Parameters:
      entity - The entity.
      location - The location.
      grave - The grave.
      plugin - The plugin instance.
      Returns:
      The safe teleport location.
    • getSafeGraveLocation

      public org.bukkit.Location getSafeGraveLocation(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, Grave grave)
      Gets a safe grave location.
      Parameters:
      livingEntity - The living entity.
      location - The location.
      grave - The grave.
      Returns:
      The safe grave location.
    • findGround

      private org.bukkit.Location findGround(org.bukkit.Location location)
      Finds the nearest solid ground below the given location. Searches downward from the starting location until a solid block is found or the search limit is reached.
      Parameters:
      location - The starting location.
      Returns:
      The location on solid ground, or the original location if no ground is found within the search limit.
    • getTop

      public org.bukkit.Location getTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
      Finds the top location for placement, searching downward from the given location's Y-coordinate.
      Parameters:
      location - The base location.
      entity - The entity.
      grave - The grave.
      Returns:
      The found top location, or null if no suitable location is found.
    • getRoof

      public org.bukkit.Location getRoof(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
      Gets the roof location for placement.
      Parameters:
      location - The location.
      entity - The entity.
      grave - The grave.
      Returns:
      The roof location.
    • getGround

      public org.bukkit.Location getGround(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
      Gets the ground location for placement.
      Parameters:
      location - The location.
      entity - The entity.
      grave - The grave.
      Returns:
      The ground location.
    • findLocationDownFromY

      private org.bukkit.Location findLocationDownFromY(org.bukkit.Location location, org.bukkit.entity.Entity entity, int y, Grave grave)
      Attempts to find a safe grave location by searching downward from a specified Y-coordinate. The search will: - Start at the given Y level. - Look for either lava or water (and use getLavaTop or getWaterTop), or a safe and grave-free location. - Stop once the world’s minimum height is reached.
      Parameters:
      location - The base location.
      entity - The entity.
      y - The starting Y-coordinate.
      grave - The grave.
      Returns:
      A safe downward location, or null if none found.
    • findLocationUpFromY

      private org.bukkit.Location findLocationUpFromY(org.bukkit.Location location, org.bukkit.entity.Entity entity, int y, Grave grave)
      Attempts to find a safe grave location by searching upward from a specified Y-coordinate. The search will: - Start at the given Y level. - Look for either lava or water (and use getLavaTop or getWaterTop), or a safe and grave-free location. - Stop once the world’s max height is reached.
      Parameters:
      location - The base location.
      entity - The entity.
      y - The starting Y-coordinate.
      grave - The grave.
      Returns:
      A safe upward location, or null if none found.
    • getVoid

      public org.bukkit.Location getVoid(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
      Gets the void location for placement.
      Parameters:
      location - The location.
      entity - The entity.
      grave - The grave.
      Returns:
      The void location.
    • getLavaTop

      public org.bukkit.Location getLavaTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
      Gets the top location above lava for placement.
      Parameters:
      location - The location to check.
      entity - The entity.
      grave - The grave.
      Returns:
      The lava top location, or null if no valid location is found.
    • getWaterTop

      public org.bukkit.Location getWaterTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave)
      Gets the top location above water for placement.
      Parameters:
      location - The location to check.
      entity - The entity.
      grave - The grave.
      Returns:
      The water top location, or null if no valid location is found.
    • canBuild

      public boolean canBuild(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, List<String> permissionList)
      Determines if a living entity can build at a specified location.
      Parameters:
      livingEntity - The living entity.
      location - The location.
      permissionList - The list of permissions.
      Returns:
      True if the entity can build, otherwise false.
    • isLocationSafePlayer

      public boolean isLocationSafePlayer(org.bukkit.Location location)
      Determines if a location is safe for a player to spawn or teleport to. A location is considered safe if: - It is inside the world border. - The current block and block above are not solid or lava. - The block below is solid and not lava.
      Parameters:
      location - The location to check.
      Returns:
      True if the location is safe; otherwise, false.
    • isLocationSafeGrave

      public boolean isLocationSafeGrave(org.bukkit.Location location)
      Determines if a location is safe for a grave.
      Parameters:
      location - The location.
      Returns:
      True if the location is safe, otherwise false.
    • hasGrave

      public boolean hasGrave(org.bukkit.Location location)
      Determines if a location has a grave.
      Parameters:
      location - The location.
      Returns:
      True if the location has a grave, otherwise false.
    • isInsideBorder

      public boolean isInsideBorder(org.bukkit.Location location)
      Determines if a location is inside the world border. For versions prior to 1.12, the world border is ignored and this always returns true.
      Parameters:
      location - The location to check.
      Returns:
      True if the location is inside the world border; otherwise, false.
    • isVoid

      public boolean isVoid(org.bukkit.Location location)
      Determines if the specified location is in the void. A location is considered in the void if it's below the world's minimum height or above its maximum build height.
      Parameters:
      location - The location to check.
      Returns:
      True if the location is in the void; otherwise, false.
    • getMinHeight

      public int getMinHeight(org.bukkit.Location location)
      Gets the minimum height for a location.
      Parameters:
      location - The location.
      Returns:
      The minimum height.