Class SubAreaManager

java.lang.Object
me.tayebyassine.homestead.managers.SubAreaManager

public final class SubAreaManager extends Object
A utility class that manages SubArea.
  • 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 region
      name - the sub-area name
      world - the world
      point1 - the first corner point
      point2 - 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 ID
      name - the sub-area name
      world - the world
      point1 - the first corner point
      point2 - the second corner point
      flags - default global player flags
      Returns:
      the created sub-area
    • getAll

      public static List<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

      public static int getSubAreaCount(Region region)
      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

      public static boolean hasSubAreas(Region region)
      Checks if a region has any sub-areas.
      Parameters:
      region - the region
      Returns:
      true if sub-areas exist
    • hasSubAreas

      public static boolean hasSubAreas(long regionId)
      Checks if a region has any sub-areas.
      Parameters:
      regionId - the region ID
      Returns:
      true if sub-areas exist
    • getSubAreasOfRegion

      public static List<SubArea> getSubAreasOfRegion(Region region)
      Get sub-areas of a region.
      Parameters:
      region - the region
      Returns:
      list of sub-areas
    • getSubAreasOfRegion

      public static List<SubArea> getSubAreasOfRegion(long regionId)
      Get sub-areas of a region.
      Parameters:
      regionId - the region ID
      Returns:
      list of sub-areas
    • getSubAreasInWorld

      public static List<SubArea> getSubAreasInWorld(org.bukkit.World world)
      Returns all sub-areas in a specific world.
      Parameters:
      world - the world
      Returns:
      list of sub-areas
    • getSubAreasInWorld

      public static List<SubArea> getSubAreasInWorld(UUID worldId)
      Returns all sub-areas in a specific world.
      Parameters:
      worldId - the world UUID
      Returns:
      list of sub-areas
    • getSubAreaNames

      public static List<String> getSubAreaNames(Region region)
      Returns all sub-area names for a region (useful for GUIs).
      Parameters:
      region - the region
      Returns:
      list of names
    • getSubAreaNames

      public static List<String> getSubAreaNames(long regionId)
      Returns all sub-area names for a region.
      Parameters:
      regionId - the region ID
      Returns:
      list of names
    • findSubArea

      public static SubArea findSubArea(long id)
      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

      public static SubArea findSubArea(long regionId, String name)
      Retrieves the sub-area with the exact name (case-insensitive) within a region, or null if none exists.
      Parameters:
      regionId - the region ID
      name - the sub-area name
      Returns:
      the sub-area, or null
    • getPlayerSubAreas

      public static List<SubArea> getPlayerSubAreas(org.bukkit.entity.Player player)
      Returns all sub-areas a player is a member of.
      Parameters:
      player - the player
      Returns:
      list of sub-areas
    • getPlayerSubAreas

      public static List<SubArea> getPlayerSubAreas(UUID playerId)
      Returns all sub-areas a player is a member of.
      Parameters:
      playerId - the player UUID
      Returns:
      list of sub-areas
    • findSubAreaHasBlockInside

      public static SubArea findSubAreaHasBlockInside(org.bukkit.block.Block block)
      Finds the sub-area containing the given block.
      Parameters:
      block - the block
      Returns:
      the sub-area, or null
    • findSubAreaHasLocationInside

      public static SubArea findSubAreaHasLocationInside(org.bukkit.Location location)
      Finds the sub-area containing the given location.
      Parameters:
      location - the location
      Returns:
      the sub-area, or null
    • findSubAreaByLocationInRegion

      public static SubArea findSubAreaByLocationInRegion(org.bukkit.Location location, long regionId)
      Finds the sub-area containing the given location, scoped to a specific region.
      Parameters:
      location - the location
      regionId - 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:
      true if 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:
      true if inside any sub-area
    • isPlayerInSubArea

      public static boolean isPlayerInSubArea(org.bukkit.entity.Player player, SubArea subArea)
      Checks if a player is currently inside a specific sub-area.
      Parameters:
      player - the player
      subArea - the sub-area
      Returns:
      true if the player is inside
    • getSubAreasIntersecting

      public static List<SubArea> getSubAreasIntersecting(SubArea subArea)
      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

      public static List<SubArea> getSubAreasIntersectingRegion(Region region)
      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

      public static List<SubArea> getSubAreasIntersectingRegion(long regionId)
      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

      public static int getTotalVolume(Region region)
      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

      public static SubArea getLargestSubArea(Region region)
      Returns the largest sub-area in a region by volume.
      Parameters:
      region - the region
      Returns:
      the largest sub-area, or null
    • getLargestSubArea

      public static SubArea getLargestSubArea(long regionId)
      Returns the largest sub-area in a region by volume.
      Parameters:
      regionId - the region ID
      Returns:
      the largest sub-area, or null
    • getSubAreasByVolumeRange

      public static List<SubArea> getSubAreasByVolumeRange(Region region, int minVolume, int maxVolume)
      Returns sub-areas filtered by volume range.
      Parameters:
      region - the region
      minVolume - minimum volume (inclusive)
      maxVolume - maximum volume (inclusive)
      Returns:
      list of matching sub-areas
    • getSubAreasByVolumeRange

      public static List<SubArea> getSubAreasByVolumeRange(long regionId, int minVolume, int maxVolume)
      Returns sub-areas filtered by volume range.
      Parameters:
      regionId - the region ID
      minVolume - minimum volume (inclusive)
      maxVolume - maximum volume (inclusive)
      Returns:
      list of matching sub-areas
    • getSubAreaCenter

      public static org.bukkit.Location getSubAreaCenter(SubArea subArea)
      Calculates the center location of a sub-area.
      Parameters:
      subArea - the sub-area
      Returns:
      the center location, or null if world is unloaded
    • getSubAreaCorners

      public static List<org.bukkit.Location> getSubAreaCorners(SubArea subArea)
      Returns all 8 corner blocks of a sub-area.
      Parameters:
      subArea - the sub-area
      Returns:
      list of corner locations
    • renameSubArea

      public static String renameSubArea(SubArea subArea, String newName)
      Safely renames a sub-area, ensuring uniqueness within the region.
      Parameters:
      subArea - the sub-area to rename
      newName - 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-area
      point1 - the new first corner
      point2 - the new second corner
    • expandSubArea

      public static void expandSubArea(SubArea subArea, int amount)
      Expands a sub-area by the given amount in all directions.
      Parameters:
      subArea - the sub-area
      amount - 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

      public static int deleteSubAreasOfRegion(Region region)
      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

      public static boolean isNameUsed(long regionId, String name)
      Checks whether any sub-area in the region already carries the supplied name, ignoring case.
      Parameters:
      regionId - the region ID
      name - the name to check
      Returns:
      true if 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