Package org.bukkit

Interface Chunk


  • public interface Chunk
    Represents a chunk of blocks
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean addPluginChunkTicket​(Plugin plugin)
      Adds a plugin ticket for this chunk, loading this chunk if it is not already loaded.
      boolean contains​(BlockData block)
      Tests if this chunk contains the specified block.
      Block getBlock​(int x, int y, int z)
      Gets a block from this chunk
      ChunkSnapshot getChunkSnapshot()
      Capture thread-safe read-only snapshot of chunk data
      ChunkSnapshot getChunkSnapshot​(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain)
      Capture thread-safe read-only snapshot of chunk data
      Entity[] getEntities()
      Get a list of all entities in the chunk.
      long getInhabitedTime()
      Gets the amount of time in ticks that this chunk has been inhabited.
      Collection<Plugin> getPluginChunkTickets()
      Retrieves a collection specifying which plugins have tickets for this chunk.
      BlockState[] getTileEntities()
      Get a list of all tile entities in the chunk.
      World getWorld()
      Gets the world containing this chunk
      int getX()
      Gets the X-coordinate of this chunk
      int getZ()
      Gets the Z-coordinate of this chunk
      boolean isForceLoaded()
      Gets whether the chunk at the specified chunk coordinates is force loaded.
      boolean isLoaded()
      Checks if the chunk is loaded.
      boolean isSlimeChunk()
      Checks if this chunk can spawn slimes without being a swamp biome.
      boolean load()
      Loads the chunk.
      boolean load​(boolean generate)
      Loads the chunk.
      boolean removePluginChunkTicket​(Plugin plugin)
      Removes the specified plugin's ticket for this chunk
      void setForceLoaded​(boolean forced)
      Sets whether the chunk at the specified chunk coordinates is force loaded.
      void setInhabitedTime​(long ticks)
      Sets the amount of time in ticks that this chunk has been inhabited.
      boolean unload()
      Unloads and optionally saves the Chunk
      boolean unload​(boolean save)
      Unloads and optionally saves the Chunk
    • Method Detail

      • getX

        int getX()
        Gets the X-coordinate of this chunk
        Returns:
        X-coordinate
      • getZ

        int getZ()
        Gets the Z-coordinate of this chunk
        Returns:
        Z-coordinate
      • getWorld

        @NotNull
        World getWorld()
        Gets the world containing this chunk
        Returns:
        Parent World
      • getBlock

        @NotNull
        Block getBlock​(int x,
                       int y,
                       int z)
        Gets a block from this chunk
        Parameters:
        x - 0-15
        y - 0-255
        z - 0-15
        Returns:
        the Block
      • getChunkSnapshot

        @NotNull
        ChunkSnapshot getChunkSnapshot()
        Capture thread-safe read-only snapshot of chunk data
        Returns:
        ChunkSnapshot
      • getChunkSnapshot

        @NotNull
        ChunkSnapshot getChunkSnapshot​(boolean includeMaxblocky,
                                       boolean includeBiome,
                                       boolean includeBiomeTempRain)
        Capture thread-safe read-only snapshot of chunk data
        Parameters:
        includeMaxblocky - - if true, snapshot includes per-coordinate maximum Y values
        includeBiome - - if true, snapshot includes per-coordinate biome type
        includeBiomeTempRain - - if true, snapshot includes per-coordinate raw biome temperature and rainfall
        Returns:
        ChunkSnapshot
      • getEntities

        @NotNull
        Entity[] getEntities()
        Get a list of all entities in the chunk.
        Returns:
        The entities.
      • getTileEntities

        @NotNull
        BlockState[] getTileEntities()
        Get a list of all tile entities in the chunk.
        Returns:
        The tile entities.
      • isLoaded

        boolean isLoaded()
        Checks if the chunk is loaded.
        Returns:
        True if it is loaded.
      • load

        boolean load​(boolean generate)
        Loads the chunk.
        Parameters:
        generate - Whether or not to generate a chunk if it doesn't already exist
        Returns:
        true if the chunk has loaded successfully, otherwise false
      • load

        boolean load()
        Loads the chunk.
        Returns:
        true if the chunk has loaded successfully, otherwise false
      • unload

        boolean unload​(boolean save)
        Unloads and optionally saves the Chunk
        Parameters:
        save - Controls whether the chunk is saved
        Returns:
        true if the chunk has unloaded successfully, otherwise false
      • unload

        boolean unload()
        Unloads and optionally saves the Chunk
        Returns:
        true if the chunk has unloaded successfully, otherwise false
      • isSlimeChunk

        boolean isSlimeChunk()
        Checks if this chunk can spawn slimes without being a swamp biome.
        Returns:
        true if slimes are able to spawn in this chunk
      • isForceLoaded

        boolean isForceLoaded()
        Gets whether the chunk at the specified chunk coordinates is force loaded.

        A force loaded chunk will not be unloaded due to lack of player activity.

        Returns:
        force load status
        See Also:
        World.isChunkForceLoaded(int, int)
      • setForceLoaded

        void setForceLoaded​(boolean forced)
        Sets whether the chunk at the specified chunk coordinates is force loaded.

        A force loaded chunk will not be unloaded due to lack of player activity.

        Parameters:
        forced - force load status
        See Also:
        World.setChunkForceLoaded(int, int, boolean)
      • addPluginChunkTicket

        boolean addPluginChunkTicket​(@NotNull
                                     Plugin plugin)
        Adds a plugin ticket for this chunk, loading this chunk if it is not already loaded.

        A plugin ticket will prevent a chunk from unloading until it is explicitly removed. A plugin instance may only have one ticket per chunk, but each chunk can have multiple plugin tickets.

        Parameters:
        plugin - Plugin which owns the ticket
        Returns:
        true if a plugin ticket was added, false if the ticket already exists for the plugin
        Throws:
        IllegalStateException - If the specified plugin is not enabled
        See Also:
        World.addPluginChunkTicket(int, int, Plugin)
      • removePluginChunkTicket

        boolean removePluginChunkTicket​(@NotNull
                                        Plugin plugin)
        Removes the specified plugin's ticket for this chunk

        A plugin ticket will prevent a chunk from unloading until it is explicitly removed. A plugin instance may only have one ticket per chunk, but each chunk can have multiple plugin tickets.

        Parameters:
        plugin - Plugin which owns the ticket
        Returns:
        true if the plugin ticket was removed, false if there is no plugin ticket for the chunk
        See Also:
        World.removePluginChunkTicket(int, int, Plugin)
      • getPluginChunkTickets

        @NotNull
        Collection<Plugin> getPluginChunkTickets()
        Retrieves a collection specifying which plugins have tickets for this chunk. This collection is not updated when plugin tickets are added or removed to this chunk.

        A plugin ticket will prevent a chunk from unloading until it is explicitly removed. A plugin instance may only have one ticket per chunk, but each chunk can have multiple plugin tickets.

        Returns:
        unmodifiable collection containing which plugins have tickets for this chunk
        See Also:
        World.getPluginChunkTickets(int, int)
      • getInhabitedTime

        long getInhabitedTime()
        Gets the amount of time in ticks that this chunk has been inhabited. Note that the time is incremented once per tick per player in the chunk.
        Returns:
        inhabited time
      • setInhabitedTime

        void setInhabitedTime​(long ticks)
        Sets the amount of time in ticks that this chunk has been inhabited.
        Parameters:
        ticks - new inhabited time
      • contains

        boolean contains​(@NotNull
                         BlockData block)
        Tests if this chunk contains the specified block.
        Parameters:
        block - block to test
        Returns:
        if the block is contained within