java.lang.Object
net.paulem.arcana.regions.container.GlobalBlockContainer<S,K>
- Type Parameters:
S- the type of the object to trackK- the key used to identify the object
A container that holds all the block containers for all worlds.
This increases performance when dealing with many worlds, chunks and sections and avoid iterating over every single object.
-
Method Summary
Modifier and TypeMethodDescriptiongetAllHolders(Class<T> type) Retrieves the data of every holder across all world containers whose data is an instance of the given type.Retrieves the tracked object located at the given key, across all worlds.getOrCreateWorldContainer(UUID worldId) Retrieves the container for the given world, creating it first if it doesn't exist yet.getOrCreateWorldContainer(org.bukkit.World world) Retrieves the container for the given world, creating it first if it doesn't exist yet.@Nullable WorldBlockContainer<S, K> getWorldContainer(UUID worldId) Retrieves the container for the given world, without creating it.@Nullable WorldBlockContainer<S, K> getWorldContainer(org.bukkit.World world) Retrieves the container for the given world, without creating it.static <S extends Tracked<K>,K extends WorldKey>
GlobalBlockContainer<S, K> of()Creates a new, emptyGlobalBlockContainer.voidremoveHolder(K key) Removes the tracked object located at the given key, if any.voidremoveWorldContainer(UUID worldId) Removes the container for the given world, if present.voidStores a tracked object at the given key, creating the containers for its world/chunk/section as needed.
-
Method Details
-
of
Creates a new, emptyGlobalBlockContainer.- Type Parameters:
S- the type of the object to trackK- the key used to identify the object- Returns:
- a new
GlobalBlockContainerinstance
-
getWorldContainer
Retrieves the container for the given world, without creating it.- Parameters:
worldId- the UUID of the world- Returns:
- the world's container, or
nullif it doesn't exist yet
-
getOrCreateWorldContainer
Retrieves the container for the given world, creating it first if it doesn't exist yet.- Parameters:
worldId- the UUID of the world- Returns:
- the world's container, never
null
-
removeWorldContainer
Removes the container for the given world, if present.- Parameters:
worldId- the UUID of the world to remove
-
getWorldContainer
Retrieves the container for the given world, without creating it.- Parameters:
world- the world- Returns:
- the world's container, or
nullif it doesn't exist yet
-
getOrCreateWorldContainer
Retrieves the container for the given world, creating it first if it doesn't exist yet.- Parameters:
world- the world- Returns:
- the world's container, never
null
-
getHolder
Retrieves the tracked object located at the given key, across all worlds.- Parameters:
key- the key identifying the world and coordinates to look up- Returns:
- the tracked object at the key, or
nullif none is registered or its world has no container
-
setHolder
Stores a tracked object at the given key, creating the containers for its world/chunk/section as needed.- Parameters:
key- the key identifying the world and coordinates to store the object attracked- the object to store
-
removeHolder
Removes the tracked object located at the given key, if any.- Parameters:
key- the key identifying the world and coordinates to remove
-
getAllHolders
- Returns:
- a collection of all holders stored across every world container
-
getAllHolders
Retrieves the data of every holder across all world containers whose data is an instance of the given type.- Type Parameters:
T- the expected type of the holder's data- Parameters:
type- the class used to filter and cast each holder's data- Returns:
- a list of the data objects matching the given type
-