Class SubAreaManager
java.lang.Object
tfagaming.projects.minecraft.homestead.managers.SubAreaManager
A utility class that manages
SubArea creation, deletion, and queries.-
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 SubArea.
-
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 SubArea.
-
getAll
Returns an immutable view of every loaded sub-area.- Returns:
- List of all sub-areas.
-
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
Get sub-areas of a region.- Parameters:
region- The region- Returns:
- List of sub-areas.
-
getSubAreasOfRegion
Get sub-areas of a region.- Parameters:
regionId- The region ID- Returns:
- List of sub-areas.
-
getSubAreasInWorld
Returns all sub-areas in a specific world.- Parameters:
world- The world- Returns:
- List of sub-areas.
-
getSubAreasInWorld
Returns all sub-areas in a specific world.- Parameters:
worldId- The world UUID- Returns:
- List of sub-areas.
-
getSubAreaNames
Returns all sub-area names for a region (useful for GUIs).- Parameters:
region- The region- Returns:
- List of names.
-
getSubAreaNames
Returns all sub-area names for a region.- Parameters:
regionId- The region ID- Returns:
- List of names.
-
findSubArea
Retrieves the sub-area with the exact ID, or null if none exists.- Parameters:
id- The sub-area ID- Returns:
- The SubArea, or
null.
-
findSubArea
Retrieves the sub-area with the exact name (case-insensitive) within a region, or null if none exists.- Parameters:
regionId- The region IDname- The sub-area name- Returns:
- The SubArea, or
null.
-
findSubAreaHasBlockInside
Finds the sub-area containing the given block.- Parameters:
block- The block- Returns:
- The SubArea, or
null.
-
findSubAreaHasLocationInside
Finds the sub-area containing the given location.- Parameters:
location- The location- Returns:
- The SubArea, 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 SubArea, 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
Returns all sub-areas that intersect (overlap) with the given sub-area.- Parameters:
subArea- The sub-area to check- Returns:
- List of intersecting sub-areas (excluding itself).
-
getSubAreasIntersectingRegion
Returns all sub-areas in a region that intersect with region chunks.- Parameters:
region- The region- Returns:
- List of sub-areas that overlap with the region's claimed chunks.
-
getSubAreasIntersectingRegion
Returns all sub-areas in a region that intersect with region chunks.- Parameters:
regionId- The region ID- Returns:
- List of sub-areas that overlap with the region's claimed chunks.
-
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
Returns the largest sub-area in a region by volume.- Parameters:
region- The region- Returns:
- The largest SubArea, or
null.
-
getLargestSubArea
Returns the largest sub-area in a region by volume.- Parameters:
regionId- The region ID- Returns:
- The largest SubArea, or
null.
-
getSubAreasByVolumeRange
Returns sub-areas filtered by volume range.- Parameters:
region- The regionminVolume- Minimum volume (inclusive)maxVolume- Maximum volume (inclusive)- Returns:
- List of matching sub-areas.
-
getSubAreasByVolumeRange
Returns sub-areas filtered by volume range.- Parameters:
regionId- The region IDminVolume- Minimum volume (inclusive)maxVolume- Maximum volume (inclusive)- Returns:
- List of matching sub-areas.
-
getSubAreaCenter
Calculates the center location of a sub-area.- Parameters:
subArea- The sub-area- Returns:
- The center location, or
nullif world is unloaded.
-
getSubAreaCorners
Returns all 8 corner blocks of a sub-area.- Parameters:
subArea- The sub-area- Returns:
- List of corner locations.
-
getPlayerSubAreas
Returns all sub-areas a player is a member of.- Parameters:
player- The player- Returns:
- List of sub-areas.
-
getPlayerSubAreas
Returns all sub-areas a player is a member of.- Parameters:
playerId- The player UUID- Returns:
- List of sub-areas.
-
renameSubArea
Safely renames a sub-area, ensuring uniqueness within the region.- Parameters:
subArea- The sub-area to renamenewName- The desired name- Returns:
- The actual name assigned (may have counter appended).
-
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.
-