Class PowerBlockManager
java.lang.Object
nl.pim16aap2.animatedarchitecture.core.api.restartable.Restartable
nl.pim16aap2.animatedarchitecture.core.managers.PowerBlockManager
- All Implemented Interfaces:
IRestartable,StructureDeletionManager.IDeletionListener
@Singleton
public final class PowerBlockManager
extends Restartable
implements StructureDeletionManager.IDeletionListener
Manages all power block interactions.
-
Method Summary
Modifier and TypeMethodDescriptionvoidinvalidateChunk(String worldName, Vector2Di chunk) Invalidates the cache of a chunk in a world.booleanisAnimatedArchitectureWorld(String worldName) Checks if a world is a AnimatedArchitecture world.voidLoads a world.voidonStructureAddOrRemove(String worldName, Vector3Di pos) Invalidates the cache for when a structure is either added to a world or removed from it.voidonStructureDeletion(IStructureConst structure) Called when a structure is deleted.voidshutDown()Handles a shutdown.structuresFromPowerBlockLoc(ILocation location) Gets allStructures that have a powerblock at a location in a world.structuresFromPowerBlockLoc(Vector3Di loc, String worldName) Gets allStructures that have a powerblock at a location in a world.structuresFromPowerBlockLoc(Vector3Di loc, IWorld world) Gets allStructures that have a powerblock at a location in a world.structuresInChunk(Vector3Di loc, String worldName) Retrieves all structures whose powerblocks exist in the same chunk as a given location.voidunloadWorld(String worldName) Unloads a world from the cache.voidupdatePowerBlockLoc(Structure structure, Vector3Di oldPos, Vector3Di newPos) Updates the position of the power block of aStructurein the database.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nl.pim16aap2.animatedarchitecture.core.api.restartable.IRestartable
initialize
-
Method Details
-
unloadWorld
Unloads a world from the cache.- Parameters:
worldName- The name of the world to unload.
-
loadWorld
Loads a world.- Parameters:
worldName- The name of the world.
-
structuresFromPowerBlockLoc
Gets allStructures that have a powerblock at a location in a world.- Parameters:
location- The location.- Returns:
- All
Structures that have a powerblock at a location in a world.
-
structuresFromPowerBlockLoc
Gets allStructures that have a powerblock at a location in a world.- Parameters:
loc- The location.world- The world.- Returns:
- All
Structures that have a powerblock at a location in a world.
-
structuresFromPowerBlockLoc
public CompletableFuture<List<Structure>> structuresFromPowerBlockLoc(Vector3Di loc, String worldName) Gets allStructures that have a powerblock at a location in a world.- Parameters:
loc- The location.worldName- The name of the world.- Returns:
- All
Structures that have a powerblock at a location in a world.
-
structuresInChunk
Retrieves all structures whose powerblocks exist in the same chunk as a given location.- Parameters:
loc- The location.worldName- The name of the world to search in.- Returns:
- The UIDs of the structures that whose powerblocks lie in the same chunk as the location.
-
isAnimatedArchitectureWorld
Checks if a world is a AnimatedArchitecture world. In other words, it checks if a world contains more than 0 structures.- Parameters:
worldName- The name of the world.- Returns:
- True if the world contains at least 1 structure.
-
updatePowerBlockLoc
Updates the position of the power block of aStructurein the database.- Parameters:
structure- TheStructure.oldPos- The old position.newPos- The new position.
-
onStructureAddOrRemove
Invalidates the cache for when a structure is either added to a world or removed from it.- Parameters:
worldName- The name of the world of the structure.pos- The position of the structure's power block.
-
invalidateChunk
Invalidates the cache of a chunk in a world.- Parameters:
worldName- The name of the world.chunk- The location (x,z) of the chunk in chunk-space.
-
shutDown
public void shutDown()Description copied from interface:IRestartableHandles a shutdown.- Specified by:
shutDownin interfaceIRestartable
-
onStructureDeletion
Description copied from interface:StructureDeletionManager.IDeletionListenerCalled when a structure is deleted.- Specified by:
onStructureDeletionin interfaceStructureDeletionManager.IDeletionListener- Parameters:
structure- The structure that was deleted.
-