Class SubArea
java.lang.Object
me.tayebyassine.homestead.models.SubArea
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
ConstructorsConstructorDescriptionSubArea(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 TypeMethodDescriptionlongGet the creation timestamp.intgetMaxX()Get the maximum x coordinate.intgetMaxY()Get the maximum y coordinate.intgetMaxZ()Get the maximum z coordinate.intgetMinX()Get the minimum x coordinate.intgetMinY()Get the minimum y coordinate.intgetMinZ()Get the minimum z coordinate.@NotNull StringgetName()Get the sub-area name.longGet the player flags bitmask.@NotNull SeBlockGet the first corner block.@NotNull SeBlockGet the second corner block.@Nullable RegionGet the parent region from the cache.longGet the parent region ID.@NotNull StringGet the parent region's name safely.@NotNull SeRentgetRent()Get the rent configuration.longGet the unique snowflake ID.intGet the total block volume.@Nullable org.bukkit.WorldgetWorld()Get the Bukkit world.@NotNull UUIDGet the world UUID.booleanisBlockInside(SeBlock block) Check whether a serialisable block is inside this sub-area.booleanisBlockInside(org.bukkit.block.Block block) Check whether a Bukkit block is inside this sub-area.booleanisIntersecting(SubArea other) Check whether this sub-area intersects another.booleanisLocationInside(SeLocation location) Check whether a serializable location is inside this sub-area.booleanisLocationInside(org.bukkit.Location location) Check whether a Bukkit location is inside this sub-area.voidSet the sub-area name.voidsetPlayerFlags(long playerFlags) Set the player flags bitmask.voidSet the first corner from a serialisable block.voidsetPoint1(@NotNull org.bukkit.block.Block block) Set the first corner from a Bukkit block.voidSet the second corner from a serialisable block.voidsetPoint2(@NotNull org.bukkit.block.Block block) Set the second corner from a Bukkit block.voidsetRegionId(long regionId) Set the parent region ID.voidSet the rent configuration.voidsetWorldId(@NotNull UUID worldId) Set the world UUID.
-
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 IDname- the sub-area nameworld- the worldpoint1- the first corner blockpoint2- the second corner blockplayerFlags- 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 IDregionId- the parent region IDname- the sub-area nameworldId- the world UUIDpoint1- the first corner blockpoint2- the second corner blockplayerFlags- the player flagsrent- the rent datacreatedAt- 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 IDregionId- the parent region IDname- the sub-area nameworldId- the world UUIDpoint1- the first cornerpoint2- the second cornerplayerFlags- the player flagsrent- the rent datacreatedAt- 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
Get the parent region from the cache.- Returns:
- the region, or
nullif not found
-
getRegionName
Get the parent region's name safely. Returns"?"if not found.- Returns:
- the region name
-
getName
-
setName
Set the sub-area name.- Parameters:
name- the new name
-
getWorldId
-
setWorldId
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
nullif not loaded
-
getPoint1
-
setPoint1
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
Get the second corner block.- Returns:
- the second corner
-
setPoint2
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
Check whether a serialisable block is inside this sub-area.- Parameters:
block- the block to test- Returns:
trueif 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:
trueif the block is inside
-
isLocationInside
Check whether a serializable location is inside this sub-area.- Parameters:
location- the location to test- Returns:
trueif 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:
trueif the location is inside
-
isIntersecting
Check whether this sub-area intersects another.- Parameters:
other- the other sub-area- Returns:
trueif 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
Get the rent configuration. Always returns a non-null instance.- Returns:
- the rent
-
setRent
Set the rent configuration.- Parameters:
rent- the new rent, ornullto reset to defaults
-