Class RegionChunk

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

public final class RegionChunk extends Object
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

    Constructors
    Constructor
    Description
    RegionChunk(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 Type
    Method
    Description
    boolean
     
    long
    Get the claim timestamp.
    @Nullable Region
    Get the parent region from the cache.
    long
    Get the owning region ID.
    @NotNull String
    Get the parent region's name safely.
    long
    Get the unique snowflake ID.
    @Nullable org.bukkit.World
    Get the Bukkit world.
    @NotNull UUID
    Get the world UUID.
    int
    Get the chunk x coordinate.
    int
    Get the chunk z coordinate.
    int
     
    boolean
    Whether the chunk is force-loaded.
    void
    setClaimedAt(long claimedAt)
    Set the claim timestamp.
    void
    setForceLoaded(boolean forceLoaded)
    Set whether the chunk is force-loaded.
    void
    setRegionId(long regionId)
    Set the owning region ID.
    @Nullable org.bukkit.Chunk
    Convert this chunk claim to a Bukkit chunk.
    @Nullable org.bukkit.Location
    Convert to a Bukkit location without the highest-block-Y adjustment.
    @Nullable org.bukkit.Location
    Convert to a Bukkit location at the center of the chunk surface.

    Methods inherited from class Object

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

    • RegionChunk

      public RegionChunk(long regionId, org.bukkit.Chunk chunk)
      Create a chunk claim from a Bukkit chunk.
      Parameters:
      regionId - the owning region ID
      chunk - 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 ID
      world - the world
      x - the chunk x coordinate
      z - the chunk z coordinate
    • RegionChunk

      public RegionChunk(long regionId, UUID worldId, int x, int z, long claimedAt, boolean forceLoaded)
      Create a chunk claim with a generated snowflake ID.
      Parameters:
      regionId - the owning region ID
      worldId - the world UUID
      x - the chunk x coordinate
      z - the chunk z coordinate
      claimedAt - the claim timestamp
      forceLoaded - 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 ID
      regionId - the owning region ID
      worldId - the world UUID
      x - the chunk x coordinate
      z - the chunk z coordinate
      claimedAt - the claim timestamp
      forceLoaded - 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

      @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
    • getWorldId

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

      @Nullable public @Nullable org.bukkit.World getWorld()
      Get the Bukkit world.
      Returns:
      the world, or null if 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:
      true if force-loaded
    • setForceLoaded

      public void setForceLoaded(boolean forceLoaded)
      Set whether the chunk is force-loaded.
      Parameters:
      forceLoaded - true to force-load
    • toBukkit

      @Nullable public @Nullable org.bukkit.Chunk toBukkit()
      Convert this chunk claim to a Bukkit chunk.
      Returns:
      the chunk, or null if 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 null if 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 null if the world is not loaded
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object