Class WorldBlockContainer<S extends Tracked<K>,K extends WorldKey>

java.lang.Object
net.paulem.arcana.regions.container.WorldBlockContainer<S,K>
Type Parameters:
S - The type of the tracked entities being managed, which extends Tracked.
K - The type of the key associated with the tracked entities, which extends WorldKey.
All Implemented Interfaces:
SubContainerHolderAccessor<S,K>

public class WorldBlockContainer<S extends Tracked<K>,K extends WorldKey> extends Object implements SubContainerHolderAccessor<S,K>
Represents a container for managing block-related data across a specific world, organized into smaller chunk-based containers.
  • Method Details

    • of

      public static <S extends Tracked<K>, K extends WorldKey> WorldBlockContainer<S,K> of(UUID worldId)
      Creates a new, empty WorldBlockContainer for the given world.
      Type Parameters:
      S - the type of the tracked entities being managed
      K - the type of the key associated with the tracked entities
      Parameters:
      worldId - the UUID of the world this container manages
      Returns:
      a new WorldBlockContainer instance
    • of

      public static <S extends Tracked<K>, K extends WorldKey> WorldBlockContainer<S,K> of(org.bukkit.World world)
      Creates a new, empty WorldBlockContainer for the given world.
      Type Parameters:
      S - the type of the tracked entities being managed
      K - the type of the key associated with the tracked entities
      Parameters:
      world - the world this container manages
      Returns:
      a new WorldBlockContainer instance
    • getWorld

      public org.bukkit.World getWorld()
      Returns:
      the World this container manages, resolved from its UUID, or null if that world isn't currently loaded
    • getChunkContainer

      @Nullable public @Nullable ChunkBlockContainer<S,K> getChunkContainer(ChunkKey key)
      Retrieves the container for the given chunk, without creating it.
      Parameters:
      key - the chunk's key
      Returns:
      the chunk's container, or null if it doesn't exist yet
    • getOrCreateChunkContainer

      public ChunkBlockContainer<S,K> getOrCreateChunkContainer(ChunkKey key)
      Retrieves the container for the given chunk, creating it first if it doesn't exist yet.
      Parameters:
      key - the chunk's key
      Returns:
      the chunk's container, never null
    • removeChunkContainer

      public void removeChunkContainer(ChunkKey key)
      Removes the container for the given chunk, if present.
      Parameters:
      key - the key of the chunk to remove
    • removeChunkContainer

      public void removeChunkContainer(org.bukkit.Chunk chunk)
      Removes the container for the given chunk, if present.
      Parameters:
      chunk - the chunk to remove
    • getHolder

      @Nullable public S getHolder(int x, int y, int z)
      Retrieves the tracked object at the given coordinates, using the chunk container that contains them.
      Specified by:
      getHolder in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      Returns:
      the tracked object at the given coordinates, or null if its chunk isn't tracked or no object is stored there
    • setHolder

      public void setHolder(int x, int y, int z, S holder)
      Stores a tracked object at the given coordinates, creating the chunk container for those coordinates if needed.
      Specified by:
      setHolder in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      holder - the tracked object to store
    • removeHolder

      public void removeHolder(int x, int y, int z)
      Removes the tracked object at the given coordinates, if its chunk is tracked.
      Specified by:
      removeHolder in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
    • getAllHolders

      public Collection<Holder<S,K>> getAllHolders()
      Specified by:
      getAllHolders in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Returns:
      a collection of all holders stored across every chunk in this world