Class SubAreaManager
java.lang.Object
me.tayebyassine.homestead.managers.SubAreaManager
-
Method Summary
Modifier and TypeMethodDescriptionstatic intRemoves all sub-areas with invalid references: - Worlds that no longer exist - Regions that no longer exist - Members whose player UUID no longer maps to a known playerstatic SubAreacreateSubArea(long regionId, String name, org.bukkit.World world, org.bukkit.block.Block point1, org.bukkit.block.Block point2, long flags) Create a new sub-area.static SubAreacreateSubArea(Region region, String name, org.bukkit.World world, org.bukkit.block.Block point1, org.bukkit.block.Block point2) Create a new sub-area.static voiddeleteSubArea(long id) Permanently deletes the specified sub-area and its related members.static intdeleteSubAreasOfRegion(long regionId) Deletes all sub-areas belonging to a region.static intdeleteSubAreasOfRegion(Region region) Deletes all sub-areas belonging to a region.static voidexpandSubArea(SubArea subArea, int amount) Expands a sub-area by the given amount in all directions.static SubAreafindSubArea(long id) Retrieves the sub-area with the exact ID, or null if none exists.static SubAreafindSubArea(long regionId, String name) Retrieves the sub-area with the exact name (case-insensitive) within a region, or null if none exists.static SubAreafindSubAreaByLocationInRegion(org.bukkit.Location location, long regionId) Finds the sub-area containing the given location, scoped to a specific region.static SubAreafindSubAreaHasBlockInside(org.bukkit.block.Block block) Finds the sub-area containing the given block.static SubAreafindSubAreaHasLocationInside(org.bukkit.Location location) Finds the sub-area containing the given location.getAll()Returns an immutable view of every loaded sub-area.static SubAreagetLargestSubArea(long regionId) Returns the largest sub-area in a region by volume.static SubAreagetLargestSubArea(Region region) Returns the largest sub-area in a region by volume.getPlayerSubAreas(UUID playerId) Returns all sub-areas a player is a member of.getPlayerSubAreas(org.bukkit.entity.Player player) Returns all sub-areas a player is a member of.static org.bukkit.LocationgetSubAreaCenter(SubArea subArea) Calculates the center location of a sub-area.static List<org.bukkit.Location> getSubAreaCorners(SubArea subArea) Returns all 8 corner blocks of a sub-area.static intReturns the number of sub-areas in the server.static intgetSubAreaCount(long regionId) Returns the number of sub-areas in a region.static intgetSubAreaCount(Region region) Returns the number of sub-areas in a region.getSubAreaNames(long regionId) Returns all sub-area names for a region.getSubAreaNames(Region region) Returns all sub-area names for a region (useful for GUIs).getSubAreasByVolumeRange(long regionId, int minVolume, int maxVolume) Returns sub-areas filtered by volume range.getSubAreasByVolumeRange(Region region, int minVolume, int maxVolume) Returns sub-areas filtered by volume range.getSubAreasIntersecting(SubArea subArea) Returns all sub-areas that intersect (overlap) with the given sub-area.getSubAreasIntersectingRegion(long regionId) Returns all sub-areas in a region that intersect with region chunks.getSubAreasIntersectingRegion(Region region) Returns all sub-areas in a region that intersect with region chunks.getSubAreasInWorld(UUID worldId) Returns all sub-areas in a specific world.getSubAreasInWorld(org.bukkit.World world) Returns all sub-areas in a specific world.getSubAreasOfRegion(long regionId) Get sub-areas of a region.getSubAreasOfRegion(Region region) Get sub-areas of a region.static intgetTotalVolume(long regionId) Returns the total volume (in blocks) of all sub-areas in a region.static intgetTotalVolume(Region region) Returns the total volume (in blocks) of all sub-areas in a region.static booleanhasSubAreas(long regionId) Checks if a region has any sub-areas.static booleanhasSubAreas(Region region) Checks if a region has any sub-areas.static booleanisBlockInAnySubArea(org.bukkit.block.Block block) Checks if a block is inside any sub-area on the server.static booleanisLocationInAnySubArea(org.bukkit.Location location) Checks if a location is inside any sub-area on the server.static booleanisNameUsed(long regionId, String name) Checks whether any sub-area in the region already carries the supplied name, ignoring case.static booleanisPlayerInSubArea(org.bukkit.entity.Player player, SubArea subArea) Checks if a player is currently inside a specific sub-area.static StringrenameSubArea(SubArea subArea, String newName) Safely renames a sub-area, ensuring uniqueness within the region.static voidresizeSubArea(SubArea subArea, org.bukkit.block.Block point1, org.bukkit.block.Block point2) Resizes a sub-area to new corner points.
-
Method Details
-
createSubArea
public static SubArea createSubArea(Region region, String name, org.bukkit.World world, org.bukkit.block.Block point1, org.bukkit.block.Block point2) Create a new sub-area.- Parameters:
region- the regionname- the sub-area nameworld- the worldpoint1- the first corner pointpoint2- the second corner point- Returns:
- the created sub-area
-
createSubArea
public static SubArea createSubArea(long regionId, String name, org.bukkit.World world, org.bukkit.block.Block point1, org.bukkit.block.Block point2, long flags) Create a new sub-area.- Parameters:
regionId- the region IDname- the sub-area nameworld- the worldpoint1- the first corner pointpoint2- the second corner pointflags- default global player flags- Returns:
- the created sub-area
-
getAll
-
getSubAreaCount
public static int getSubAreaCount()Returns the number of sub-areas in the server.- Returns:
- sub-area count
-
getSubAreaCount
Returns the number of sub-areas in a region.- Parameters:
region- the region- Returns:
- sub-area count
-
getSubAreaCount
public static int getSubAreaCount(long regionId) Returns the number of sub-areas in a region.- Parameters:
regionId- the region ID- Returns:
- sub-area count
-
hasSubAreas
Checks if a region has any sub-areas.- Parameters:
region- the region- Returns:
trueif sub-areas exist
-
hasSubAreas
public static boolean hasSubAreas(long regionId) Checks if a region has any sub-areas.- Parameters:
regionId- the region ID- Returns:
trueif sub-areas exist
-
getSubAreasOfRegion
-
getSubAreasOfRegion
-
getSubAreasInWorld
-
getSubAreasInWorld
-
getSubAreaNames
-
getSubAreaNames
-
findSubArea
Retrieves the sub-area with the exact ID, or null if none exists.- Parameters:
id- the sub-area ID- Returns:
- the sub-area, or
null
-
findSubArea
-
getPlayerSubAreas
-
getPlayerSubAreas
-
findSubAreaHasBlockInside
Finds the sub-area containing the given block.- Parameters:
block- the block- Returns:
- the sub-area, or
null
-
findSubAreaHasLocationInside
Finds the sub-area containing the given location.- Parameters:
location- the location- Returns:
- the sub-area, or
null
-
findSubAreaByLocationInRegion
Finds the sub-area containing the given location, scoped to a specific region.- Parameters:
location- the locationregionId- the region ID to search within- Returns:
- the sub-area, or
null
-
isLocationInAnySubArea
public static boolean isLocationInAnySubArea(org.bukkit.Location location) Checks if a location is inside any sub-area on the server.- Parameters:
location- the location- Returns:
trueif inside any sub-area
-
isBlockInAnySubArea
public static boolean isBlockInAnySubArea(org.bukkit.block.Block block) Checks if a block is inside any sub-area on the server.- Parameters:
block- the block- Returns:
trueif inside any sub-area
-
isPlayerInSubArea
Checks if a player is currently inside a specific sub-area.- Parameters:
player- the playersubArea- the sub-area- Returns:
trueif the player is inside
-
getSubAreasIntersecting
-
getSubAreasIntersectingRegion
-
getSubAreasIntersectingRegion
-
getTotalVolume
Returns the total volume (in blocks) of all sub-areas in a region.- Parameters:
region- the region- Returns:
- total volume
-
getTotalVolume
public static int getTotalVolume(long regionId) Returns the total volume (in blocks) of all sub-areas in a region.- Parameters:
regionId- the region ID- Returns:
- total volume
-
getLargestSubArea
-
getLargestSubArea
Returns the largest sub-area in a region by volume.- Parameters:
regionId- the region ID- Returns:
- the largest sub-area, or
null
-
getSubAreasByVolumeRange
-
getSubAreasByVolumeRange
-
getSubAreaCenter
Calculates the center location of a sub-area.- Parameters:
subArea- the sub-area- Returns:
- the center location, or
nullif world is unloaded
-
getSubAreaCorners
-
renameSubArea
-
resizeSubArea
public static void resizeSubArea(SubArea subArea, org.bukkit.block.Block point1, org.bukkit.block.Block point2) Resizes a sub-area to new corner points.- Parameters:
subArea- the sub-areapoint1- the new first cornerpoint2- the new second corner
-
expandSubArea
Expands a sub-area by the given amount in all directions.- Parameters:
subArea- the sub-areaamount- blocks to expand (must be positive)
-
deleteSubArea
public static void deleteSubArea(long id) Permanently deletes the specified sub-area and its related members.- Parameters:
id- the sub-area ID
-
deleteSubAreasOfRegion
Deletes all sub-areas belonging to a region.- Parameters:
region- the region- Returns:
- the number of sub-areas deleted
-
deleteSubAreasOfRegion
public static int deleteSubAreasOfRegion(long regionId) Deletes all sub-areas belonging to a region.- Parameters:
regionId- the region ID- Returns:
- the number of sub-areas deleted
-
isNameUsed
Checks whether any sub-area in the region already carries the supplied name, ignoring case.- Parameters:
regionId- the region IDname- the name to check- Returns:
trueif the name is used
-
cleanupInvalidSubAreas
public static int cleanupInvalidSubAreas()Removes all sub-areas with invalid references: - Worlds that no longer exist - Regions that no longer exist - Members whose player UUID no longer maps to a known player- Returns:
- number of corrupted sub-areas removed + member fixes
-