Class RegionChunk
java.lang.Object
me.tayebyassine.homestead.models.RegionChunk
Represents a single chunk claimed by a region.
Region chunks are indexed by both region ID and world position for fast spatial lookups. Each chunk can optionally be force-loaded.
-
Constructor Summary
ConstructorsConstructorDescriptionRegionChunk(long id, long regionId, UUID worldId, int x, int z, long claimedAt, boolean forceLoaded) Create a chunk claim from pre-existing data (deserialization).RegionChunk(long regionId, UUID worldId, int x, int z, long claimedAt, boolean forceLoaded) Create a chunk claim with a generated snowflake ID.RegionChunk(long regionId, org.bukkit.Chunk chunk) Create a chunk claim from a Bukkit chunk.RegionChunk(long regionId, org.bukkit.World world, int x, int z) Create a chunk claim from a world and chunk coordinates. -
Method Summary
Modifier and TypeMethodDescriptionbooleanlongGet the claim timestamp.@Nullable RegionGet the parent region from the cache.longGet the owning region ID.@NotNull StringGet the parent region's name safely.longGet the unique snowflake ID.@Nullable org.bukkit.WorldgetWorld()Get the Bukkit world.@NotNull UUIDGet the world UUID.intgetX()Get the chunk x coordinate.intgetZ()Get the chunk z coordinate.inthashCode()booleanWhether the chunk is force-loaded.voidsetClaimedAt(long claimedAt) Set the claim timestamp.voidsetForceLoaded(boolean forceLoaded) Set whether the chunk is force-loaded.voidsetRegionId(long regionId) Set the owning region ID.@Nullable org.bukkit.ChunktoBukkit()Convert this chunk claim to a Bukkit chunk.@Nullable org.bukkit.LocationConvert to a Bukkit location without the highest-block-Y adjustment.@Nullable org.bukkit.LocationConvert to a Bukkit location at the center of the chunk surface.
-
Constructor Details
-
RegionChunk
public RegionChunk(long regionId, org.bukkit.Chunk chunk) Create a chunk claim from a Bukkit chunk.- Parameters:
regionId- the owning region IDchunk- the chunk to claim
-
RegionChunk
public RegionChunk(long regionId, org.bukkit.World world, int x, int z) Create a chunk claim from a world and chunk coordinates.- Parameters:
regionId- the owning region IDworld- the worldx- the chunk x coordinatez- the chunk z coordinate
-
RegionChunk
Create a chunk claim with a generated snowflake ID.- Parameters:
regionId- the owning region IDworldId- the world UUIDx- the chunk x coordinatez- the chunk z coordinateclaimedAt- the claim timestampforceLoaded- whether the chunk is force-loaded
-
RegionChunk
public RegionChunk(long id, long regionId, UUID worldId, int x, int z, long claimedAt, boolean forceLoaded) Create a chunk claim from pre-existing data (deserialization).- Parameters:
id- the snowflake IDregionId- the owning region IDworldId- the world UUIDx- the chunk x coordinatez- the chunk z coordinateclaimedAt- the claim timestampforceLoaded- whether the chunk is force-loaded
-
-
Method Details
-
getUniqueId
public long getUniqueId()Get the unique snowflake ID.- Returns:
- the chunk ID
-
getRegionId
public long getRegionId()Get the owning region ID.- Returns:
- the region ID
-
setRegionId
public void setRegionId(long regionId) Set the owning region ID. Automatically updates the region and position indexed caches.- 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
-
getWorldId
-
getWorld
@Nullable public @Nullable org.bukkit.World getWorld()Get the Bukkit world.- Returns:
- the world, or
nullif not loaded
-
getX
public int getX()Get the chunk x coordinate.- Returns:
- the x coordinate
-
getZ
public int getZ()Get the chunk z coordinate.- Returns:
- the z coordinate
-
getClaimedAt
public long getClaimedAt()Get the claim timestamp.- Returns:
- the epoch-millis timestamp
-
setClaimedAt
public void setClaimedAt(long claimedAt) Set the claim timestamp.- Parameters:
claimedAt- the new timestamp
-
isForceLoaded
public boolean isForceLoaded()Whether the chunk is force-loaded.- Returns:
trueif force-loaded
-
setForceLoaded
public void setForceLoaded(boolean forceLoaded) Set whether the chunk is force-loaded.- Parameters:
forceLoaded-trueto force-load
-
toBukkit
@Nullable public @Nullable org.bukkit.Chunk toBukkit()Convert this chunk claim to a Bukkit chunk.- Returns:
- the chunk, or
nullif the world is not loaded
-
toBukkitLocation
@Nullable public @Nullable org.bukkit.Location toBukkitLocation()Convert to a Bukkit location at the center of the chunk surface.- Returns:
- the location, or
nullif the world is not loaded
-
toBukkitDisplayLocation
@Nullable public @Nullable org.bukkit.Location toBukkitDisplayLocation()Convert to a Bukkit location without the highest-block-Y adjustment. Used for display/map purposes.- Returns:
- the location, or
nullif the world is not loaded
-
equals
-
hashCode
-