Class SubArea

java.lang.Object
me.tayebyassine.homestead.models.SubArea

public final class SubArea extends Object
A rectangular sub-area within a parent region.

Sub-areas allow regions to be partitioned into smaller parcels that can have independent flags and optionally be rented out. Each sub-area is defined by two corner blocks (point1 and point2) within a single world.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SubArea(long id, long regionId, String name, UUID worldId, SeBlock point1, SeBlock point2, long playerFlags, SeRent rent, long createdAt)
    Create a sub-area from pre-existing data (deserialization).
    SubArea(long id, long regionId, String name, UUID worldId, org.bukkit.block.Block point1, org.bukkit.block.Block point2, long playerFlags, SeRent rent, long createdAt)
    Create a sub-area from Bukkit blocks with deserialised rent data.
    SubArea(long regionId, String name, org.bukkit.World world, org.bukkit.block.Block point1, org.bukkit.block.Block point2, long playerFlags)
    Create a new sub-area with a generated snowflake ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Get the creation timestamp.
    int
    Get the maximum x coordinate.
    int
    Get the maximum y coordinate.
    int
    Get the maximum z coordinate.
    int
    Get the minimum x coordinate.
    int
    Get the minimum y coordinate.
    int
    Get the minimum z coordinate.
    @NotNull String
    Get the sub-area name.
    long
    Get the player flags bitmask.
    @NotNull SeBlock
    Get the first corner block.
    @NotNull SeBlock
    Get the second corner block.
    @Nullable Region
    Get the parent region from the cache.
    long
    Get the parent region ID.
    @NotNull String
    Get the parent region's name safely.
    @NotNull SeRent
    Get the rent configuration.
    long
    Get the unique snowflake ID.
    int
    Get the total block volume.
    @Nullable org.bukkit.World
    Get the Bukkit world.
    @NotNull UUID
    Get the world UUID.
    boolean
    Check whether a serialisable block is inside this sub-area.
    boolean
    isBlockInside(org.bukkit.block.Block block)
    Check whether a Bukkit block is inside this sub-area.
    boolean
    Check whether this sub-area intersects another.
    boolean
    Check whether a serializable location is inside this sub-area.
    boolean
    isLocationInside(org.bukkit.Location location)
    Check whether a Bukkit location is inside this sub-area.
    void
    setName(@NotNull String name)
    Set the sub-area name.
    void
    setPlayerFlags(long playerFlags)
    Set the player flags bitmask.
    void
    setPoint1(@NotNull SeBlock point1)
    Set the first corner from a serialisable block.
    void
    setPoint1(@NotNull org.bukkit.block.Block block)
    Set the first corner from a Bukkit block.
    void
    setPoint2(@NotNull SeBlock point2)
    Set the second corner from a serialisable block.
    void
    setPoint2(@NotNull org.bukkit.block.Block block)
    Set the second corner from a Bukkit block.
    void
    setRegionId(long regionId)
    Set the parent region ID.
    void
    setRent(@Nullable SeRent rent)
    Set the rent configuration.
    void
    setWorldId(@NotNull UUID worldId)
    Set the world UUID.

    Methods inherited from class Object

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

    • SubArea

      public SubArea(long regionId, String name, org.bukkit.World world, org.bukkit.block.Block point1, org.bukkit.block.Block point2, long playerFlags)
      Create a new sub-area with a generated snowflake ID.
      Parameters:
      regionId - the parent region ID
      name - the sub-area name
      world - the world
      point1 - the first corner block
      point2 - the second corner block
      playerFlags - the initial player flags
    • SubArea

      public SubArea(long id, long regionId, String name, UUID worldId, org.bukkit.block.Block point1, org.bukkit.block.Block point2, long playerFlags, SeRent rent, long createdAt)
      Create a sub-area from Bukkit blocks with deserialised rent data.
      Parameters:
      id - the snowflake ID
      regionId - the parent region ID
      name - the sub-area name
      worldId - the world UUID
      point1 - the first corner block
      point2 - the second corner block
      playerFlags - the player flags
      rent - the rent data
      createdAt - the creation timestamp
    • SubArea

      public SubArea(long id, long regionId, String name, UUID worldId, SeBlock point1, SeBlock point2, long playerFlags, SeRent rent, long createdAt)
      Create a sub-area from pre-existing data (deserialization).
      Parameters:
      id - the snowflake ID
      regionId - the parent region ID
      name - the sub-area name
      worldId - the world UUID
      point1 - the first corner
      point2 - the second corner
      playerFlags - the player flags
      rent - the rent data
      createdAt - the creation timestamp
  • Method Details

    • getUniqueId

      public long getUniqueId()
      Get the unique snowflake ID.
      Returns:
      the sub-area ID
    • getCreatedAt

      public long getCreatedAt()
      Get the creation timestamp.
      Returns:
      the epoch-millis timestamp
    • getRegionId

      public long getRegionId()
      Get the parent region ID.
      Returns:
      the region ID
    • setRegionId

      public void setRegionId(long regionId)
      Set the parent region ID.
      Parameters:
      regionId - the new region ID
    • getRegion

      @Nullable public @Nullable Region getRegion()
      Get the parent region from the cache.
      Returns:
      the region, or null if not found
    • getRegionName

      @NotNull public @NotNull String getRegionName()
      Get the parent region's name safely. Returns "?" if not found.
      Returns:
      the region name
    • getName

      @NotNull public @NotNull String getName()
      Get the sub-area name.
      Returns:
      the name
    • setName

      public void setName(@NotNull @NotNull String name)
      Set the sub-area name.
      Parameters:
      name - the new name
    • getWorldId

      @NotNull public @NotNull UUID getWorldId()
      Get the world UUID.
      Returns:
      the world UUID
    • setWorldId

      public void setWorldId(@NotNull @NotNull UUID worldId)
      Set the world UUID.
      Parameters:
      worldId - the new world UUID
    • getWorld

      @Nullable public @Nullable org.bukkit.World getWorld()
      Get the Bukkit world.
      Returns:
      the world, or null if not loaded
    • getPoint1

      @NotNull public @NotNull SeBlock getPoint1()
      Get the first corner block.
      Returns:
      the first corner
    • setPoint1

      public void setPoint1(@NotNull @NotNull SeBlock point1)
      Set the first corner from a serialisable block.
      Parameters:
      point1 - the new corner
    • setPoint1

      public void setPoint1(@NotNull @NotNull org.bukkit.block.Block block)
      Set the first corner from a Bukkit block.
      Parameters:
      block - the new corner
    • getPoint2

      @NotNull public @NotNull SeBlock getPoint2()
      Get the second corner block.
      Returns:
      the second corner
    • setPoint2

      public void setPoint2(@NotNull @NotNull SeBlock point2)
      Set the second corner from a serialisable block.
      Parameters:
      point2 - the new corner
    • setPoint2

      public void setPoint2(@NotNull @NotNull org.bukkit.block.Block block)
      Set the second corner from a Bukkit block.
      Parameters:
      block - the new corner
    • getMinX

      public int getMinX()
      Get the minimum x coordinate.
      Returns:
      the minimum x
    • getMaxX

      public int getMaxX()
      Get the maximum x coordinate.
      Returns:
      the maximum x
    • getMinY

      public int getMinY()
      Get the minimum y coordinate.
      Returns:
      the minimum y
    • getMaxY

      public int getMaxY()
      Get the maximum y coordinate.
      Returns:
      the maximum y
    • getMinZ

      public int getMinZ()
      Get the minimum z coordinate.
      Returns:
      the minimum z
    • getMaxZ

      public int getMaxZ()
      Get the maximum z coordinate.
      Returns:
      the maximum z
    • getVolume

      public int getVolume()
      Get the total block volume.
      Returns:
      width × height × depth
    • isBlockInside

      public boolean isBlockInside(SeBlock block)
      Check whether a serialisable block is inside this sub-area.
      Parameters:
      block - the block to test
      Returns:
      true if the block is inside
    • isBlockInside

      public boolean isBlockInside(org.bukkit.block.Block block)
      Check whether a Bukkit block is inside this sub-area.
      Parameters:
      block - the block to test
      Returns:
      true if the block is inside
    • isLocationInside

      public boolean isLocationInside(SeLocation location)
      Check whether a serializable location is inside this sub-area.
      Parameters:
      location - the location to test
      Returns:
      true if the location is inside
    • isLocationInside

      public boolean isLocationInside(org.bukkit.Location location)
      Check whether a Bukkit location is inside this sub-area.
      Parameters:
      location - the location to test
      Returns:
      true if the location is inside
    • isIntersecting

      public boolean isIntersecting(SubArea other)
      Check whether this sub-area intersects another.
      Parameters:
      other - the other sub-area
      Returns:
      true if they overlap
    • getPlayerFlags

      public long getPlayerFlags()
      Get the player flags bitmask.
      Returns:
      the player flags
    • setPlayerFlags

      public void setPlayerFlags(long playerFlags)
      Set the player flags bitmask.
      Parameters:
      playerFlags - the new flags
    • getRent

      @NotNull public @NotNull SeRent getRent()
      Get the rent configuration. Always returns a non-null instance.
      Returns:
      the rent
    • setRent

      public void setRent(@Nullable @Nullable SeRent rent)
      Set the rent configuration.
      Parameters:
      rent - the new rent, or null to reset to defaults