Class StargateRegistry
- All Implemented Interfaces:
RegistryAPI
- Author:
- Thorin (idea from EpicKnarvik)
-
Constructor Summary
ConstructorsConstructorDescriptionStargateRegistry(StorageAPI storageAPI, BlockHandlerResolver blockHandlerResolver) Instantiates a new Stargate registry -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear this registry@Nullable NetworkgetNetwork(String id, StorageType storageType) Gets the network with the givengetNetworkRegistry(StorageType storageType) Get the network registrygetPortal(org.bukkit.Location location) Get the portal at the given locationgetPortal(org.bukkit.Location location, GateStructureType structureType) Gets the portal with the given structure type at the given locationgetPortal(org.bukkit.Location location, GateStructureType[] structureTypes) Gets the portal with any of the given structure types at the given locationgetPortal(BlockLocation blockLocation, GateStructureType structureType) Get the portal with the given structure type at the given locationgetPortal(BlockLocation blockLocation, GateStructureType[] structureTypes) Get the portal with any of the given structure types at the given locationgetPortalPosition(org.bukkit.Location location) Gets the portal position at given locationGet all portal positionsgetPortalPositionsOwnedByPlugin(org.bukkit.plugin.Plugin plugin) getPortalsFromTouchingBlock(org.bukkit.Location location, GateStructureType structureType) Get portal from block next to portal, will randomly choose one portal if block is next to two portals@NotNull Set<RealPortal> getPortalsInChunk(StargateChunk chunk) Get all the portals in a chunkgetValidNewName(Network network) Get a non-clashing name close to the current name of the network.booleanisNextToPortal(org.bukkit.Location location, GateStructureType structureType) Checks one block away from the given location to check if it's adjacent to a portal structurebooleanisPartOfPortal(List<org.bukkit.block.Block> blocks) Checks if any of the given blocks belong to a portalbooleannetworkExists(String networkName, StorageType storageType) Checks whether the given network name existsvoidregisterLocation(GateStructureType structureType, BlockLocation location, RealPortal portal) Registers a location with attached portal and structure type to this registryvoidregisterLocations(GateStructureType structureType, Map<BlockLocation, RealPortal> locationsMap) Registers the existence of the given structure type in the given locationsvoidregisterNetwork(Network network) UseNetworkManagerinstead.voidregisterPortal(@NotNull RealPortal portal) Register a portal to this registryvoidregisterPortalPosition(PortalPosition portalPosition, org.bukkit.Location location, RealPortal portal) Register given portal position to registry.voidremovePortalPosition(org.bukkit.Location location) Remove portal position from registryvoidrenameNetwork(String newId, String oldId, StorageType storageType) UseNetworkManagerinstead.savePortalPosition(RealPortal portal, org.bukkit.Location location, PositionType type, org.bukkit.plugin.Plugin plugin) Save given portal position to storage and register it to the registryvoidunRegisterLocation(GateStructureType structureType, BlockLocation blockLocation) Un-registers all portal blocks with the given structure type, at the given block locationvoidunregisterPortal(Portal portal) Removes the given portal from registry.voidUpdate all portals handled by this registry
-
Constructor Details
-
StargateRegistry
Instantiates a new Stargate registry- Parameters:
storageAPI-The database API to use for interfacing with the database
-
-
Method Details
-
unregisterPortal
Description copied from interface:RegistryAPIRemoves the given portal from registry. Only modifies this registry, useNetworkManager.destroyPortal(RealPortal)instead- Specified by:
unregisterPortalin interfaceRegistryAPI- Parameters:
portal-The portal to remove
-
registerPortal
Description copied from interface:RegistryAPIRegister a portal to this registry- Specified by:
registerPortalin interfaceRegistryAPI- Parameters:
portal-The portal to register
-
networkExists
Description copied from interface:RegistryAPIChecks whether the given network name exists- Specified by:
networkExistsin interfaceRegistryAPI- Parameters:
networkName-The network name to check
storageType-The storage type of the network
- Returns:
True if the network exists
-
getNetworkRegistry
Description copied from interface:RegistryAPIGet the network registry- Specified by:
getNetworkRegistryin interfaceRegistryAPI- Parameters:
storageType-- Returns:
-
getNetwork
Description copied from interface:RegistryAPIGets the network with the given- Specified by:
getNetworkin interfaceRegistryAPI- Parameters:
id-The id of the network to get
storageType-Whether the network is a BungeeCord network
- Returns:
The network with the given name
-
updateAllPortals
public void updateAllPortals()Description copied from interface:RegistryAPIUpdate all portals handled by this registry- Specified by:
updateAllPortalsin interfaceRegistryAPI
-
getPortal
Description copied from interface:RegistryAPIGet the portal with the given structure type at the given location- Specified by:
getPortalin interfaceRegistryAPI- Parameters:
blockLocation-The location the portal is located at
structureType-The structure type to look for
- Returns:
The found portal, or null if no such portal exists
-
getPortal
Description copied from interface:RegistryAPIGet the portal with any of the given structure types at the given location- Specified by:
getPortalin interfaceRegistryAPI- Parameters:
blockLocation-The location the portal is located at
structureTypes-The structure types to look for
- Returns:
The found portal, or null if no such portal exists
-
getPortal
Description copied from interface:RegistryAPIGets the portal with the given structure type at the given location- Specified by:
getPortalin interfaceRegistryAPI- Parameters:
location-The location to check for portal structures
structureType-The structure type to look for
- Returns:
The found portal, or null if no portal was found
-
getPortal
Description copied from interface:RegistryAPIGets the portal with any of the given structure types at the given location- Specified by:
getPortalin interfaceRegistryAPI- Parameters:
location-The location to check for portal structures
structureTypes-The structure types to look for
- Returns:
The found portal, or null if no portal was found
-
getPortal
Description copied from interface:RegistryAPIGet the portal at the given location- Specified by:
getPortalin interfaceRegistryAPI- Parameters:
location-The location to check for portal structures
- Returns:
The found portal, or null if no portal was found
-
isPartOfPortal
Description copied from interface:RegistryAPIChecks if any of the given blocks belong to a portal- Specified by:
isPartOfPortalin interfaceRegistryAPI- Parameters:
blocks-The blocks to check
- Returns:
True if any of the given blocks belong to a portal
-
isNextToPortal
Description copied from interface:RegistryAPIChecks one block away from the given location to check if it's adjacent to a portal structureChecks North, west, south, east direction. Not up / down, as it is currently not necessary and a waste of resources.
- Specified by:
isNextToPortalin interfaceRegistryAPI- Parameters:
location-The location to check for adjacency
structureType-The structure type to look for
- Returns:
True if the given location is adjacent to a location containing the given structure type
-
getPortalsFromTouchingBlock
public List<RealPortal> getPortalsFromTouchingBlock(org.bukkit.Location location, GateStructureType structureType) Description copied from interface:RegistryAPIGet portal from block next to portal, will randomly choose one portal if block is next to two portals- Specified by:
getPortalsFromTouchingBlockin interfaceRegistryAPI- Parameters:
location-The location to check for
structureType-The structure type to check for
- Returns:
-
registerLocations
public void registerLocations(GateStructureType structureType, Map<BlockLocation, RealPortal> locationsMap) Description copied from interface:RegistryAPIRegisters the existence of the given structure type in the given locationsStores the portals that exist at the given locations, but using the structure type as the key to be able to check locations for the given structure type.
Does not save to storage!
- Specified by:
registerLocationsin interfaceRegistryAPI- Parameters:
structureType-The structure type to register
locationsMap-The locations and the corresponding portals to register
-
registerLocation
public void registerLocation(GateStructureType structureType, BlockLocation location, RealPortal portal) Description copied from interface:RegistryAPIRegisters a location with attached portal and structure type to this registry- Specified by:
registerLocationin interfaceRegistryAPI- Parameters:
structureType-The structure type to register
location-The location to register
portal-The portal to register
-
unRegisterLocation
Description copied from interface:RegistryAPIUn-registers all portal blocks with the given structure type, at the given block location- Specified by:
unRegisterLocationin interfaceRegistryAPI- Parameters:
structureType-The type of structure to un-register
blockLocation-The location to un-register
-
clear
public void clear()Clear this registry -
getValidNewName
Description copied from interface:RegistryAPIGet a non-clashing name close to the current name of the network.- Specified by:
getValidNewNamein interfaceRegistryAPI- Parameters:
network-The network to rename
- Throws:
InvalidNameException-If the name is a uuid
-
getPortalPositions
Description copied from interface:RegistryAPIGet all portal positions- Specified by:
getPortalPositionsin interfaceRegistryAPI- Returns:
Data on all portal positions
-
getPortalPositionsOwnedByPlugin
public Map<BlockLocation,PortalPosition> getPortalPositionsOwnedByPlugin(org.bukkit.plugin.Plugin plugin) - Specified by:
getPortalPositionsOwnedByPluginin interfaceRegistryAPI- Parameters:
plugin-The plugin owning the positions
- Returns:
Data on the portal positions owned by specified plugin
-
savePortalPosition
public PortalPosition savePortalPosition(RealPortal portal, org.bukkit.Location location, PositionType type, org.bukkit.plugin.Plugin plugin) Description copied from interface:RegistryAPISave given portal position to storage and register it to the registry- Specified by:
savePortalPositionin interfaceRegistryAPI- Parameters:
portal-The portal the position is linked to
location-The location of the position
type-The type of the position
plugin-The plugin this position relates to
-
removePortalPosition
public void removePortalPosition(org.bukkit.Location location) Description copied from interface:RegistryAPIRemove portal position from registry- Specified by:
removePortalPositionin interfaceRegistryAPI- Parameters:
location-The location of the portal position
-
registerPortalPosition
public void registerPortalPosition(PortalPosition portalPosition, org.bukkit.Location location, RealPortal portal) Description copied from interface:RegistryAPIRegister given portal position to registry. Does not save to database, therefore internal- Specified by:
registerPortalPositionin interfaceRegistryAPI- Parameters:
portalPosition-The portal position
location-The location of the position
portal-The portal of the position
-
getPortalPosition
Description copied from interface:RegistryAPIGets the portal position at given location- Specified by:
getPortalPositionin interfaceRegistryAPI- Parameters:
location-The location of the portal position
- Returns:
The portal position, or null if none was found
-
registerNetwork
Description copied from interface:RegistryAPIUseNetworkManagerinstead. This does not save to database, and is not cross server compatible- Specified by:
registerNetworkin interfaceRegistryAPI- Parameters:
network-The network to register
-
renameNetwork
public void renameNetwork(String newId, String oldId, StorageType storageType) throws InvalidNameException, UnimplementedFlagException, NameLengthException Description copied from interface:RegistryAPIUseNetworkManagerinstead. This does not save to database, and is not cross server compatible- Specified by:
renameNetworkin interfaceRegistryAPI- Parameters:
newId-The new id of the network
oldId-The old id of the network
- Throws:
InvalidNameExceptionUnimplementedFlagExceptionNameLengthException
-
getPortalsInChunk
Description copied from interface:RegistryAPIGet all the portals in a chunk- Specified by:
getPortalsInChunkin interfaceRegistryAPI- Parameters:
chunk-The chunk to retrieve portals from
- Returns:
The portals in the chunk
-