Class LocationManager
-
Constructor Summary
ConstructorsConstructorDescriptionLocationManager(Graves plugin) Initializes a new instance of the LocationManager class. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBuild(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, List<String> permissionList) Determines if a living entity can build at a specified location.org.bukkit.LocationGets the ground location for placement.org.bukkit.LocationgetLastSolidLocation(org.bukkit.entity.Entity entity) Gets the last solid location of an entity.org.bukkit.LocationgetLavaTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave) Gets the top location above lava for placement.intgetMinHeight(org.bukkit.Location location) Gets the minimum height for a location.org.bukkit.LocationgetNewLocationIfCachedGraveExists(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, Grave grave) Returns a new location if a cached grave already exists at the provided location.org.bukkit.LocationGets the roof location for placement.org.bukkit.LocationgetSafeGraveLocation(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, Grave grave) Gets a safe grave location.org.bukkit.LocationgetSafeTeleportLocation(org.bukkit.entity.Entity entity, org.bukkit.Location location, Grave grave, Graves plugin) Gets a safe teleport location.org.bukkit.LocationFinds the top location for placement, searching downward from the given location's Y-coordinate.org.bukkit.LocationgetWaterTop(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave) Gets the top location above water for placement.booleanhasCachedGraveAt(org.bukkit.Location location) Determines if a location has a grave using the cache manager grave map.booleanhasGrave(org.bukkit.Location location) Determines if a location has a grave.booleanisInsideBorder(org.bukkit.Location location) Determines if a location is inside the world border.booleanisLocationSafeGrave(org.bukkit.Location location) Determines if a location is safe for a grave.booleanisLocationSafePlayer(org.bukkit.Location location) Determines if a location is safe for a player to spawn or teleport to.booleanisNetherRoofPlacement(org.bukkit.Location location, Grave grave) Checks whether placing a grave at the given location would put it on the Nether roof.booleanisVoid(org.bukkit.Location location) Determines if the specified location is in the void.voidremoveLastSolidLocation(org.bukkit.entity.Entity entity) Removes the last solid location of an entity.voidsetLastSolidLocation(org.bukkit.entity.Entity entity, org.bukkit.Location location) Sets the last solid location of an entity.
-
Constructor Details
-
LocationManager
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.Returns
nullif:- No last location is stored,
- The stored location is in a different world than the entity's current world,
- The block below the stored location is not considered a safe solid block.
- Parameters:
entity- The entity.- Returns:
- The last solid location, or
nullif none is valid.
-
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.This method attempts to return a location that is safe for a player/entity to teleport to:
- If
teleport.unsafeis enabled, the provided location is returned as-is (as long as it has a world). - Otherwise, the location must pass
isLocationSafePlayer(Location). - If unsafe and
teleport.topis enabled, a top-safe candidate is searched and returned if valid.
- Parameters:
entity- The entity.location- The location.grave- The grave.plugin- The plugin instance.- Returns:
- The safe teleport location, or
nullif none is found/allowed.
- If
-
getSafeGraveLocation
public org.bukkit.Location getSafeGraveLocation(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, Grave grave) Gets a safe grave location.All returned locations are rounded using
LocationUtil.roundLocation(Location).- Parameters:
livingEntity- The living entity.location- The location.grave- The grave.- Returns:
- The safe grave location, or
nullif no suitable location is found.
-
hasCachedGraveAt
public boolean hasCachedGraveAt(org.bukkit.Location location) Determines if a location has a grave using the cache manager grave map.- Parameters:
location- The location.- Returns:
- True if the location has a cached grave, otherwise false.
-
getNewLocationIfCachedGraveExists
public org.bukkit.Location getNewLocationIfCachedGraveExists(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.Location location, Grave grave) Returns a new location if a cached grave already exists at the provided location.This does NOT update the cache or the grave. It only computes a new location that can be used by the caller to move/place the grave elsewhere.
- Parameters:
livingEntity- The living entity (used for safe-location logic).location- The desired location.grave- The grave being placed/moved.- Returns:
- A new safe location if the desired location is occupied; otherwise the original (rounded) location.
Returns
nullif the location is occupied and no suitable alternative could be found.
-
isNetherRoofPlacement
Checks whether placing a grave at the given location would put it on the Nether roof.- Parameters:
location- the candidate grave location (entity/grave position, not block center-only)- Returns:
trueif this would be considered a Nether roof placement, otherwisefalse
-
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.This method starts scanning from the world's max build height downwards (or from the provided location's Y if the world is unavailable) and returns the first safe position it finds.
- Parameters:
location- The base location.entity- The entity.grave- The grave.- Returns:
- The found top location, or
nullif 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.This searches upward starting just above the current Y level to find a safe position suitable for a grave.
- Parameters:
location- The location.entity- The entity.grave- The grave.- Returns:
- The roof location, or
nullif none is found.
-
getGround
public org.bukkit.Location getGround(org.bukkit.Location location, org.bukkit.entity.Entity entity, Grave grave) Gets the ground location for placement.This searches downward from the current Y level to find a safe position suitable for a grave.
- Parameters:
location- The location.entity- The entity.grave- The grave.- Returns:
- The ground location, or
nullif none is found.
-
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.Behavior:
- If
placement.lava-smartis enabled, attempts to use the entity's last solid location first. - If
placement.lava-topis enabled, scans upward from the provided location until out of lava, then searches for the first air block without title/protected data to place into.
- Parameters:
location- The location to check.entity- The entity.grave- The grave.- Returns:
- The lava top location, or
nullif no valid location is found.
- If
-
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.Behavior mirrors
getLavaTop(Location, Entity, Grave):- If
placement.water-smartis enabled, attempts to use the entity's last solid location first. - If
placement.water-topis enabled, scans upward out of water and then finds the first air block without title/protected data.
- Parameters:
location- The location to check.entity- The entity.grave- The grave.- Returns:
- The water top location, or
nullif no valid location is found.
- If
-
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.- 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.- 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.
-