Class ChunkData

java.lang.Object
com.ranull.graves.data.ChunkData
All Implemented Interfaces:
Serializable

public class ChunkData extends Object implements Serializable
Represents data for a specific chunk in the game world, including block and entity data.
See Also:
  • Constructor Details

    • ChunkData

      public ChunkData(org.bukkit.Location location)
      Constructs a new ChunkData instance based on a location.
      Parameters:
      location - The location within the chunk.
    • ChunkData

      public ChunkData(String worldName, int chunkX, int chunkZ)
      Constructs a new ChunkData instance using a world name and chunk coordinates (Folia-safe).

      This constructor avoids calling methods that might trigger synchronous chunk loads on Folia. It resolves the World by name without touching chunk APIs.

      Parameters:
      worldName - the name of the world containing the chunk
      chunkX - the chunk X coordinate
      chunkZ - the chunk Z coordinate
  • Method Details

    • getWorld

      public org.bukkit.World getWorld()
      Gets the world of the chunk.
      Returns:
      The world of the chunk.
    • getX

      public int getX()
      Gets the x-coordinate of the chunk.
      Returns:
      The x-coordinate of the chunk.
    • getZ

      public int getZ()
      Gets the z-coordinate of the chunk.
      Returns:
      The z-coordinate of the chunk.
    • hasData

      public boolean hasData()
      Checks if the chunk has any block or entity data.
      Returns:
      True if the chunk has data, false otherwise.
    • isLoaded

      public boolean isLoaded()
      Checks if the chunk is currently loaded.
      Returns:
      True if the chunk is loaded, false otherwise.
    • getLocation

      public org.bukkit.Location getLocation()
      Gets the location of the chunk.
      Returns:
      The location of the chunk.
    • getBlockDataMap

      public Map<org.bukkit.Location,BlockData> getBlockDataMap()
      Gets the map of block data within the chunk.
      Returns:
      The map of block data.
    • addBlockData

      public void addBlockData(BlockData blockData)
      Adds block data to the chunk.
      Parameters:
      blockData - The block data to add.
    • removeBlockData

      public void removeBlockData(org.bukkit.Location location)
      Removes block data from the chunk based on the location.
      Parameters:
      location - The location of the block data to remove.
    • getEntityDataMap

      public Map<UUID,EntityData> getEntityDataMap()
      Gets the map of entity data within the chunk.
      Returns:
      The map of entity data.
    • addEntityData

      public void addEntityData(EntityData entityData)
      Adds entity data to the chunk.
      Parameters:
      entityData - The entity data to add.
    • removeEntityData

      public void removeEntityData(EntityData entityData)
      Removes entity data from the chunk based on the entity's UUID.
      Parameters:
      entityData - The entity data to remove.