Class StargateRegistry
- All Implemented Interfaces:
RegistryAPI
- Author:
- Thorin (idea from EpicKnarvik)
-
Constructor Summary
ConstructorDescriptionStargateRegistry
(StorageAPI storageAPI, BlockHandlerResolver blockHandlerResolver) Instantiates a new Stargate registry -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear this registry@Nullable Network
getNetwork
(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.boolean
isNextToPortal
(org.bukkit.Location location, GateStructureType structureType) Checks one block away from the given location to check if it's adjacent to a portal structureboolean
isPartOfPortal
(List<org.bukkit.block.Block> blocks) Checks if any of the given blocks belong to a portalboolean
networkExists
(String networkName, StorageType storageType) Checks whether the given network name existsvoid
registerLocation
(GateStructureType structureType, BlockLocation location, RealPortal portal) Registers a location with attached portal and structure type to this registryvoid
registerLocations
(GateStructureType structureType, Map<BlockLocation, RealPortal> locationsMap) Registers the existence of the given structure type in the given locationsvoid
registerNetwork
(Network network) UseNetworkManager
instead.void
registerPortal
(@NotNull RealPortal portal) Register a portal to this registryvoid
registerPortalPosition
(PortalPosition portalPosition, org.bukkit.Location location, RealPortal portal) Register given portal position to registry.void
removePortalPosition
(org.bukkit.Location location) Remove portal position from registryvoid
renameNetwork
(String newId, String oldId, StorageType storageType) UseNetworkManager
instead.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 registryvoid
unRegisterLocation
(GateStructureType structureType, BlockLocation blockLocation) Un-registers all portal blocks with the given structure type, at the given block locationvoid
unregisterPortal
(Portal portal) Removes the given portal from registry.void
Update 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:RegistryAPI
Removes the given portal from registry. Only modifies this registry, useNetworkManager.destroyPortal(RealPortal)
instead- Specified by:
unregisterPortal
in interfaceRegistryAPI
- Parameters:
portal
-The portal to remove
-
registerPortal
Description copied from interface:RegistryAPI
Register a portal to this registry- Specified by:
registerPortal
in interfaceRegistryAPI
- Parameters:
portal
-The portal to register
-
networkExists
Description copied from interface:RegistryAPI
Checks whether the given network name exists- Specified by:
networkExists
in 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:RegistryAPI
Get the network registry- Specified by:
getNetworkRegistry
in interfaceRegistryAPI
- Parameters:
storageType
-- Returns:
-
getNetwork
Description copied from interface:RegistryAPI
Gets the network with the given- Specified by:
getNetwork
in 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:RegistryAPI
Update all portals handled by this registry- Specified by:
updateAllPortals
in interfaceRegistryAPI
-
getPortal
Description copied from interface:RegistryAPI
Get the portal with the given structure type at the given location- Specified by:
getPortal
in 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:RegistryAPI
Get the portal with any of the given structure types at the given location- Specified by:
getPortal
in 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:RegistryAPI
Gets the portal with the given structure type at the given location- Specified by:
getPortal
in 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:RegistryAPI
Gets the portal with any of the given structure types at the given location- Specified by:
getPortal
in 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:RegistryAPI
Get the portal at the given location- Specified by:
getPortal
in 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:RegistryAPI
Checks if any of the given blocks belong to a portal- Specified by:
isPartOfPortal
in interfaceRegistryAPI
- Parameters:
blocks
-The blocks to check
- Returns:
True if any of the given blocks belong to a portal
-
isNextToPortal
Description copied from interface:RegistryAPI
Checks 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:
isNextToPortal
in 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:RegistryAPI
Get portal from block next to portal, will randomly choose one portal if block is next to two portals- Specified by:
getPortalsFromTouchingBlock
in 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:RegistryAPI
Registers 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:
registerLocations
in 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:RegistryAPI
Registers a location with attached portal and structure type to this registry- Specified by:
registerLocation
in interfaceRegistryAPI
- Parameters:
structureType
-The structure type to register
location
-The location to register
portal
-The portal to register
-
unRegisterLocation
Description copied from interface:RegistryAPI
Un-registers all portal blocks with the given structure type, at the given block location- Specified by:
unRegisterLocation
in 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:RegistryAPI
Get a non-clashing name close to the current name of the network.- Specified by:
getValidNewName
in interfaceRegistryAPI
- Parameters:
network
-The network to rename
- Throws:
InvalidNameException
-If the name is a uuid
-
getPortalPositions
Description copied from interface:RegistryAPI
Get all portal positions- Specified by:
getPortalPositions
in interfaceRegistryAPI
- Returns:
Data on all portal positions
-
getPortalPositionsOwnedByPlugin
public Map<BlockLocation,PortalPosition> getPortalPositionsOwnedByPlugin(org.bukkit.plugin.Plugin plugin) - Specified by:
getPortalPositionsOwnedByPlugin
in 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:RegistryAPI
Save given portal position to storage and register it to the registry- Specified by:
savePortalPosition
in 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:RegistryAPI
Remove portal position from registry- Specified by:
removePortalPosition
in 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:RegistryAPI
Register given portal position to registry. Does not save to database, therefore internal- Specified by:
registerPortalPosition
in interfaceRegistryAPI
- Parameters:
portalPosition
-The portal position
location
-The location of the position
portal
-The portal of the position
-
getPortalPosition
Description copied from interface:RegistryAPI
Gets the portal position at given location- Specified by:
getPortalPosition
in interfaceRegistryAPI
- Parameters:
location
-The location of the portal position
- Returns:
The portal position, or null if none was found
-
registerNetwork
Description copied from interface:RegistryAPI
UseNetworkManager
instead. This does not save to database, and is not cross server compatible- Specified by:
registerNetwork
in 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:RegistryAPI
UseNetworkManager
instead. This does not save to database, and is not cross server compatible- Specified by:
renameNetwork
in interfaceRegistryAPI
- Parameters:
newId
-The new id of the network
oldId
-The old id of the network
- Throws:
InvalidNameException
UnimplementedFlagException
NameLengthException
-
getPortalsInChunk
Description copied from interface:RegistryAPI
Get all the portals in a chunk- Specified by:
getPortalsInChunk
in interfaceRegistryAPI
- Parameters:
chunk
-The chunk to retrieve portals from
- Returns:
The portals in the chunk
-