Class SQLDatabase
- All Implemented Interfaces:
StorageAPI
-
Constructor Summary
ConstructorDescriptionSQLDatabase
(SQLDatabaseAPI database, boolean usingBungee, boolean usingRemoteDatabase, TableNameConfiguration config, StoredPropertiesAPI propertiesDatabase) Instantiates a new stargate registrySQLDatabase
(SQLDatabaseAPI database, boolean usingBungee, boolean usingRemoteDatabase, StoredPropertiesAPI propertiesDatabase) Instantiates a new stargate registrySQLDatabase
(SQLDatabaseAPI database, StoredPropertiesAPI propertiesDatabase) Instantiates a new stargate registry -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFlag
(Character flagChar, Portal portal, StorageType portalType) Add a flag to a portal in the databasevoid
addFlagType
(char flagChar) Add a new flag typevoid
addPortalPosition
(RealPortal portal, StorageType portalType, PortalPosition portalPosition) Add a portalPosition to a portal in the databasevoid
addPortalPositionType
(String portalPositionTypeName) Add a new type of portalPositioncreateNetwork
(String networkName, NetworkType type, StorageType storageType) Creates a new network unassigned to a registrygetPortalMetaData
(Portal portal, StorageType portalType) Get misc data of a portalgetPortalPositionMetaData
(Portal portal, PortalPosition portalPosition, StorageType portalType) Get misc data of a portal positionvoid
load
(SQLDatabaseAPI database) Loads the database from the given API, and prepares necessary tablesvoid
loadFromStorage
(StargateAPI stargateAPI) Loads all portals from storage and adds them to the portal registryboolean
netWorkExists
(String netName, StorageType portalType) Check if the networks exists in the databasevoid
removeFlag
(Character flagChar, Portal portal, StorageType portalType) Remove a flag to a portal in the databasevoid
removePortalFromStorage
(Portal portal) Removes a portal and its associated data from storagevoid
removePortalPosition
(RealPortal portal, StorageType portalType, PortalPosition portalPosition) Remove a portalPosition to a portal in the databaseboolean
savePortalToStorage
(RealPortal portal) Saves the given portal to storagevoid
setPortalMetaData
(Portal portal, String data, StorageType portalType) Set misc data of a portalvoid
setPortalPositionMetaData
(RealPortal portal, PortalPosition portalPosition, String data, StorageType portalType) Set misc data of a portal positionvoid
"Starts" the inter-server connection by setting this server's portals as onlinevoid
updateNetworkName
(String newName, String networkName, StorageType portalType) Update the network name in the databasevoid
updatePortalName
(String newName, GlobalPortalId globalPortalId, StorageType portalType) Update the name of a portal
-
Constructor Details
-
SQLDatabase
public SQLDatabase(SQLDatabaseAPI database, StoredPropertiesAPI propertiesDatabase) throws StargateInitializationException Instantiates a new stargate registry- Parameters:
database
-The database connected to this Stargate instance
- Throws:
StargateInitializationException
-If unable to initialize the database
-
SQLDatabase
public SQLDatabase(SQLDatabaseAPI database, boolean usingBungee, boolean usingRemoteDatabase, StoredPropertiesAPI propertiesDatabase) throws SQLException Instantiates a new stargate registry- Parameters:
database
-The database used for storing portals
usingBungee
-Whether BungeeCord support is enabled
usingRemoteDatabase
-Whether a remote database, not a flatfile database is used
- Throws:
SQLException
-If an SQL exception occurs
-
SQLDatabase
public SQLDatabase(SQLDatabaseAPI database, boolean usingBungee, boolean usingRemoteDatabase, TableNameConfiguration config, StoredPropertiesAPI propertiesDatabase) throws SQLException Instantiates a new stargate registry- Parameters:
database
-The database used for storing portals
usingBungee
-Whether BungeeCord support is enabled
usingRemoteDatabase
-Whether a remote database, not a flatfile database is used
config
-The table name configuration to use
- Throws:
SQLException
-If an SQL exception occurs
-
-
Method Details
-
loadFromStorage
Description copied from interface:StorageAPI
Loads all portals from storage and adds them to the portal registry- Specified by:
loadFromStorage
in interfaceStorageAPI
- Parameters:
stargateAPI
-The stargate API
- Throws:
StorageReadException
-If unable to read from storage
-
savePortalToStorage
Description copied from interface:StorageAPI
Saves the given portal to storage- Specified by:
savePortalToStorage
in interfaceStorageAPI
- Parameters:
portal
-The portal to save
- Returns:
Whether or not the portal was successfully saved
- Throws:
StorageWriteException
-If unable to write to storage
-
removePortalFromStorage
Description copied from interface:StorageAPI
Removes a portal and its associated data from storage- Specified by:
removePortalFromStorage
in interfaceStorageAPI
- Parameters:
portal
-The portal to remove
- Throws:
StorageWriteException
-If unable to write to storage
-
load
Loads the database from the given API, and prepares necessary tables- Parameters:
database
-The database API to get a connection from
- Throws:
StargateInitializationException
-If unable to initializes the database and tables
-
createNetwork
public Network createNetwork(String networkName, NetworkType type, StorageType storageType) throws InvalidNameException, NameLengthException, UnimplementedFlagException Description copied from interface:StorageAPI
Creates a new network unassigned to a registry- Specified by:
createNetwork
in interfaceStorageAPI
- Parameters:
networkName
-The name of the new network
type
-The type of network to look for.
storageType
-Whether or not the network works across servers (I flag)
- Returns:
- The network that was created
- Throws:
InvalidNameException
-If the given network name is invalid
NameLengthException
-If a name is too long or short
UnimplementedFlagException
-If a selected flag is unimplemented
-
startInterServerConnection
Description copied from interface:StorageAPI
"Starts" the inter-server connection by setting this server's portals as online- Specified by:
startInterServerConnection
in interfaceStorageAPI
- Throws:
StorageWriteException
-If unable to write to storage
-
addFlagType
Description copied from interface:StorageAPI
Add a new flag type- Specified by:
addFlagType
in interfaceStorageAPI
- Parameters:
flagChar
-The character identifying the flag
- Throws:
StorageWriteException
-If unable to write the flag to storage
-
addFlag
public void addFlag(Character flagChar, Portal portal, StorageType portalType) throws StorageWriteException Description copied from interface:StorageAPI
Add a flag to a portal in the database- Specified by:
addFlag
in interfaceStorageAPI
- Parameters:
flagChar
-The character representation of that flag
portal
-A portal
portalType
-How the portal should be considered by the database
- Throws:
StorageWriteException
-If unable to write the flag change to storage
-
addPortalPositionType
Description copied from interface:StorageAPI
Add a new type of portalPosition- Specified by:
addPortalPositionType
in interfaceStorageAPI
- Parameters:
portalPositionTypeName
-The name of the portal type to add
- Throws:
StorageWriteException
-If unable to write the portal position type to storage
-
addPortalPosition
public void addPortalPosition(RealPortal portal, StorageType portalType, PortalPosition portalPosition) throws StorageWriteException Description copied from interface:StorageAPI
Add a portalPosition to a portal in the database- Specified by:
addPortalPosition
in interfaceStorageAPI
- Parameters:
portal
-A portal
portalType
-How the portal should be considered by the database
portalPosition
-A portal position
- Throws:
StorageWriteException
-If unable to write the new portal position to storage
-
removeFlag
public void removeFlag(Character flagChar, Portal portal, StorageType portalType) throws StorageWriteException Description copied from interface:StorageAPI
Remove a flag to a portal in the database- Specified by:
removeFlag
in interfaceStorageAPI
- Parameters:
flagChar
-The character representation of that flag
portal
-A portal
portalType
-How the portal should be considered by the database
- Throws:
StorageWriteException
-Uf unable to write the flag change to storage
-
removePortalPosition
public void removePortalPosition(RealPortal portal, StorageType portalType, PortalPosition portalPosition) throws StorageWriteException Description copied from interface:StorageAPI
Remove a portalPosition to a portal in the database- Specified by:
removePortalPosition
in interfaceStorageAPI
- Parameters:
portal
-A portal
portalType
-How the portal should be considered by the database
portalPosition
-A portal position
- Throws:
StorageWriteException
-If unable to write the portal position change to storage
-
setPortalMetaData
public void setPortalMetaData(Portal portal, String data, StorageType portalType) throws StorageWriteException Description copied from interface:StorageAPI
Set misc data of a portal- Specified by:
setPortalMetaData
in interfaceStorageAPI
- Parameters:
portal
-A portal
data
-Any data
portalType
-The portal's expected type
- Throws:
StorageWriteException
-If unable to successfully set the new portal data
-
getPortalMetaData
Description copied from interface:StorageAPI
Get misc data of a portal- Specified by:
getPortalMetaData
in interfaceStorageAPI
- Parameters:
portal
-A portal
portalType
-The portal's expected type
- Returns:
Data
- Throws:
StorageReadException
-If unable to successfully get the portal data
-
setPortalPositionMetaData
public void setPortalPositionMetaData(RealPortal portal, PortalPosition portalPosition, String data, StorageType portalType) throws StorageWriteException Description copied from interface:StorageAPI
Set misc data of a portal position- Specified by:
setPortalPositionMetaData
in interfaceStorageAPI
- Parameters:
portal
-A portal
portalPosition
-A portalPosition
data
-Any data
portalType
-The type of portal to set the data for
- Throws:
StorageWriteException
-If unable to set the metadata for the portal
-
getPortalPositionMetaData
public String getPortalPositionMetaData(Portal portal, PortalPosition portalPosition, StorageType portalType) throws StorageReadException Description copied from interface:StorageAPI
Get misc data of a portal position- Specified by:
getPortalPositionMetaData
in interfaceStorageAPI
- Parameters:
portal
-A portal
portalPosition
-A portalPosition
portalType
-The portal's expected type
- Returns:
Data
- Throws:
StorageReadException
-If unable to successfully read the portal metadata
-
updateNetworkName
public void updateNetworkName(String newName, String networkName, StorageType portalType) throws StorageWriteException Description copied from interface:StorageAPI
Update the network name in the database- Specified by:
updateNetworkName
in interfaceStorageAPI
- Parameters:
newName
-The new name of the network
networkName
-The previous name of the network
portalType
-The storage type of the network
- Throws:
StorageWriteException
-If unable to modify the database
-
updatePortalName
public void updatePortalName(String newName, GlobalPortalId globalPortalId, StorageType portalType) throws StorageWriteException Description copied from interface:StorageAPI
Update the name of a portal- Specified by:
updatePortalName
in interfaceStorageAPI
- Parameters:
newName
-The name of the portal
globalPortalId
-A portal id representing this portal
portalType
-How the portal is stored
- Throws:
StorageWriteException
-If unable to modify the database
-
netWorkExists
Description copied from interface:StorageAPI
Check if the networks exists in the database- Specified by:
netWorkExists
in interfaceStorageAPI
- Parameters:
netName
-Network name
portalType
-The storage type of the network
- Returns:
True if exists
- Throws:
StorageReadException
-If unable to read the database
-
getScheduledGatesClearing
- Specified by:
getScheduledGatesClearing
in interfaceStorageAPI
- Returns:
The gate formats of the portals scheduled to be cleared
-