Class SQLiteJDBCDriverConnection
java.lang.Object
nl.pim16aap2.animatedarchitecture.core.storage.sqlite.SQLiteJDBCDriverConnection
- All Implemented Interfaces:
IDebuggable,IStorage
@Singleton
public final class SQLiteJDBCDriverConnection
extends Object
implements IStorage, IDebuggable
An implementation of
IStorage for SQLite.-
Nested Class Summary
Nested classes/interfaces inherited from interface nl.pim16aap2.animatedarchitecture.core.storage.IStorage
IStorage.DatabaseState, IStorage.StructureFlag -
Field Summary
Fields inherited from interface nl.pim16aap2.animatedarchitecture.core.storage.IStorage
VALID_TABLE_NAME -
Constructor Summary
ConstructorsConstructorDescriptionSQLiteJDBCDriverConnection(DataSourceInfoSQLite dataSourceInfo, FlywayManager flywayManager, StructureBuilder structureBuilder, StructureRegistry structureRegistry, StructureTypeManager structureTypeManager, IWorldFactory worldFactory, DebuggableRegistry debuggableRegistry) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddOwner(long structureUID, PlayerData player, PermissionLevel permission) Adds a player as owner of a structure with at a certain permission level to a structure.booleandeleteStructureType(StructureType structureType) Deletes aStructureTypeand allStructures of this type from the database.TheIStorage.DatabaseStatethe database is in.Gets the debug information for this object.intgetOwnerCountOfStructure(long structureUID) Gets the total number of owners of a structure.getPartialIdentifiers(String input, @Nullable IPlayer player, PermissionLevel maxPermission, Collection<Property<?>> properties) Retrieves allDatabaseManager.StructureIdentifiers that start with the provided input.getPlayerData(String playerName) Tries to get all the players with a given name.getPlayerData(UUID uuid) Tries to find thePlayerDatafor a player with the givenUUID.it.unimi.dsi.fastutil.ints.Int2ObjectMap<it.unimi.dsi.fastutil.longs.LongList> getPowerBlockData(long chunkId) Gets a map of location hashes and their connected powerblocks for all structures in a chunk.getStructure(long structureUID) Gets the structure with the given structureUID and the original creator asStructureOwner;getStructure(UUID playerUUID, long structureUID) Gets the structure with the given UID for the given player at the level of ownership this player has over the structure, if any.intgetStructureCountByName(String structureName) Gets the total number of structures with the given name regardless of who owns them.intgetStructureCountForPlayer(UUID playerUUID) Gets the total number of structures own by the given player.intgetStructureCountForPlayer(UUID playerUUID, String structureName) Gets the number of structures own by the given player with the given name.getStructures(String name) Gets all the structures with the given name, regardless of who owns them.getStructures(UUID playerUUID) Gets all the structures owned by the given player.getStructures(UUID playerUUID, String name) Gets all the structures owned by the given player with the given name.getStructures(UUID playerUUID, String structureName, PermissionLevel maxPermission) Gets all the structures with the given name, owned by the player with at least a certain permission level.getStructures(UUID playerUUID, PermissionLevel maxPermission) Gets all the structures owned by a given player with at least a certain permission level.getStructuresInChunk(long chunkId) Gets a list of structure UIDs that have their rotation point in a given chunk.getStructuresOfType(String typeName) Obtains all structures of a given type.getStructuresOfType(String typeName, int version) Obtains all structures of a specific version of a given type.Inserts a new structure in the database.booleanisAnimatedArchitectureWorld(String worldName) Checks whether there are any structures in a given world.booleanremoveOwner(long structureUID, UUID playerUUID) Removes an owner of a structure.booleanremoveStructure(long structureUID) Delete the structure with the given structureUID from the database.booleanremoveStructures(UUID playerUUID, String structureName) Delete all structures owned by the given player with the given name.booleansyncStructureData(IStructureConst structure) Synchronizes anStructurestructure with the database.booleanupdatePlayerData(PlayerData playerData) Updates thePlayerDatafor a given player.
-
Constructor Details
-
SQLiteJDBCDriverConnection
@Inject public SQLiteJDBCDriverConnection(DataSourceInfoSQLite dataSourceInfo, FlywayManager flywayManager, StructureBuilder structureBuilder, StructureRegistry structureRegistry, StructureTypeManager structureTypeManager, IWorldFactory worldFactory, DebuggableRegistry debuggableRegistry)
-
-
Method Details
-
deleteStructureType
Description copied from interface:IStorageDeletes aStructureTypeand allStructures of this type from the database.Note that the
StructureTypehas to be registered before it can be deleted! It doesn't need to be enabled, though.- Specified by:
deleteStructureTypein interfaceIStorage- Parameters:
structureType- TheStructureTypeto delete.- Returns:
- True if deletion was successful.
-
insert
Description copied from interface:IStorageInserts a new structure in the database. If the insertion was successful, a newStructurewill be created with the correct structureUID. -
syncStructureData
Description copied from interface:IStorageSynchronizes anStructurestructure with the database. This will synchronize both the base and the type-specific data of theStructure.- Specified by:
syncStructureDatain interfaceIStorage- Parameters:
structure- TheIStructureConstthat describes the data of structure.- Returns:
- True if the update was successful.
-
getPartialIdentifiers
public List<DatabaseManager.StructureIdentifier> getPartialIdentifiers(String input, @Nullable @Nullable IPlayer player, PermissionLevel maxPermission, Collection<Property<?>> properties) Description copied from interface:IStorageRetrieves allDatabaseManager.StructureIdentifiers that start with the provided input.For example, this method can retrieve the identifiers "1", "10", "11", "100", etc. from an input of "1" or "MyDoor", "MyPortcullis", "MyOtherDoor", etc. from an input of "My".
- Specified by:
getPartialIdentifiersin interfaceIStorage- Parameters:
input- The partial identifier to look for.player- The player that should own the structures. May be null to disregard ownership.maxPermission- The maximum level of ownership (inclusive) this player has over the structures.properties- The properties that the structures must have. When specified, only structures that have all of these properties will be returned.- Returns:
- All
DatabaseManager.StructureIdentifiers that start with the provided input.
-
getStructure
Description copied from interface:IStorageGets the structure with the given structureUID and the original creator asStructureOwner;- Specified by:
getStructurein interfaceIStorage- Parameters:
structureUID- The UID of the structure to retrieve.- Returns:
- The structure with the given structureUID and the original creator.
-
getStructure
Description copied from interface:IStorageGets the structure with the given UID for the given player at the level of ownership this player has over the structure, if any.- Specified by:
getStructurein interfaceIStorage- Parameters:
playerUUID- The UUID of the player.structureUID- The UID of the structure to retrieve.- Returns:
- The structure if it exists and if the player is an owner of it.
-
removeStructure
public boolean removeStructure(long structureUID) Description copied from interface:IStorageDelete the structure with the given structureUID from the database.- Specified by:
removeStructurein interfaceIStorage- Parameters:
structureUID- The UID of the structure to delete.- Returns:
- True if at least 1 structure was successfully removed.
-
removeStructures
Description copied from interface:IStorageDelete all structures owned by the given player with the given name.- Specified by:
removeStructuresin interfaceIStorage- Parameters:
playerUUID- The player whose structures to delete.structureName- The name of the structures to delete.- Returns:
- True if at least 1 structure was successfully removed.
-
isAnimatedArchitectureWorld
Description copied from interface:IStorageChecks whether there are any structures in a given world.- Specified by:
isAnimatedArchitectureWorldin interfaceIStorage- Parameters:
worldName- The name of the world.- Returns:
- True if there are more than 0 structures in the given world.
-
getStructureCountForPlayer
Description copied from interface:IStorageGets the total number of structures own by the given player.- Specified by:
getStructureCountForPlayerin interfaceIStorage- Parameters:
playerUUID- The uuid of the player whose structures to count.- Returns:
- The total number of structures own by the given player.
-
getStructureCountForPlayer
Description copied from interface:IStorageGets the number of structures own by the given player with the given name.- Specified by:
getStructureCountForPlayerin interfaceIStorage- Parameters:
playerUUID- The uuid of the player whose structures to count.structureName- The name of the structure to search for.- Returns:
- The number of structures own by the given player with the given name.
-
getStructureCountByName
Description copied from interface:IStorageGets the total number of structures with the given name regardless of who owns them.- Specified by:
getStructureCountByNamein interfaceIStorage- Parameters:
structureName- The name of the structures to search for.- Returns:
- The total number of structures with the given name.
-
getOwnerCountOfStructure
public int getOwnerCountOfStructure(long structureUID) Description copied from interface:IStorageGets the total number of owners of a structure.- Specified by:
getOwnerCountOfStructurein interfaceIStorage- Parameters:
structureUID- TheStructure.- Returns:
- The total number of owners of this structure.
-
getStructures
public List<Structure> getStructures(UUID playerUUID, String structureName, PermissionLevel maxPermission) Description copied from interface:IStorageGets all the structures with the given name, owned by the player with at least a certain permission level.- Specified by:
getStructuresin interfaceIStorage- Parameters:
playerUUID- The name of the player who owns the structures.structureName- The name of the structures to search for.maxPermission- The maximum level of ownership (inclusive) this player has over the structures.- Returns:
- All the structures with the given name, owned the player with at least a certain permission level.
-
getStructures
Description copied from interface:IStorageGets all the structures owned by the given player with the given name.- Specified by:
getStructuresin interfaceIStorage- Parameters:
playerUUID- The UUID of the player to search for.name- The name of the structures to search for.- Returns:
- All structures owned by the given player with the given name.
-
getStructures
Description copied from interface:IStorageGets all the structures with the given name, regardless of who owns them.- Specified by:
getStructuresin interfaceIStorage- Parameters:
name- The name of the structures to search for.- Returns:
- All structures with the given name or an empty Optional if none exist.
-
getStructures
Description copied from interface:IStorageGets all the structures owned by a given player with at least a certain permission level.- Specified by:
getStructuresin interfaceIStorage- Parameters:
playerUUID- The name of the player who owns the structures.maxPermission- The maximum level of ownership (inclusive) this player has over the structures.- Returns:
- All the structures owned by the player with at least a certain permission level.
-
getStructures
Description copied from interface:IStorageGets all the structures owned by the given player.- Specified by:
getStructuresin interfaceIStorage- Parameters:
playerUUID- The UUID of the player to search for.- Returns:
- All structures owned by the given player.
-
getStructuresOfType
Description copied from interface:IStorageObtains all structures of a given type.- Specified by:
getStructuresOfTypein interfaceIStorage- Parameters:
typeName- The name of the type. SeeStructureType.getFullKey().- Returns:
- All structures of the given type.
-
getStructuresOfType
Description copied from interface:IStorageObtains all structures of a specific version of a given type.- Specified by:
getStructuresOfTypein interfaceIStorage- Parameters:
typeName- The name of the type. SeeStructureType.getFullKey().version- The version of the type.- Returns:
- All structures of the given type.
-
updatePlayerData
Description copied from interface:IStorageUpdates thePlayerDatafor a given player.- Specified by:
updatePlayerDatain interfaceIStorage- Parameters:
playerData- ThePlayerDatathe represents a player.- Returns:
- True if at least 1 record was modified.
-
getPlayerData
Description copied from interface:IStorageTries to find thePlayerDatafor a player with the givenUUID.- Specified by:
getPlayerDatain interfaceIStorage- Parameters:
uuid- TheUUIDof a player.- Returns:
- The
PlayerDatathat represents the player.
-
getPlayerData
Description copied from interface:IStorageTries to get all the players with a given name. Because names are not unique, this may result in any number of matches.If you know the player's UUID, it is recommended to use
IStorage.getPlayerData(UUID)instead.- Specified by:
getPlayerDatain interfaceIStorage- Parameters:
playerName- The name of the player(s).- Returns:
- All the players with the given name.
-
getPowerBlockData
public it.unimi.dsi.fastutil.ints.Int2ObjectMap<it.unimi.dsi.fastutil.longs.LongList> getPowerBlockData(long chunkId) Description copied from interface:IStorageGets a map of location hashes and their connected powerblocks for all structures in a chunk.The key is the hashed location in chunk space, the value is the list of UIDs of the structures whose powerblocks occupies that location.
- Specified by:
getPowerBlockDatain interfaceIStorage- Parameters:
chunkId- The id of the chunk the structures are in.- Returns:
- A map of location hashes and their connected powerblocks for all structures in a chunk.
-
getStructuresInChunk
Description copied from interface:IStorageGets a list of structure UIDs that have their rotation point in a given chunk.- Specified by:
getStructuresInChunkin interfaceIStorage- Parameters:
chunkId- The id of the chunk the structures are in.- Returns:
- A list of structures that have their rotation point in a given chunk.
-
removeOwner
Description copied from interface:IStorageRemoves an owner of a structure. Note that the original creator can never be removed.- Specified by:
removeOwnerin interfaceIStorage- Parameters:
structureUID- The UID of the structure to modify.playerUUID- The UUID of the player to remove as owner of the structure.- Returns:
- True if an owner was removed.
-
addOwner
Description copied from interface:IStorageAdds a player as owner of a structure with at a certain permission level to a structure.Note that permission level 0 is reserved for the creator, and negative values are not allowed.
-
getDebugInformation
Description copied from interface:IDebuggableGets the debug information for this object.- Specified by:
getDebugInformationin interfaceIDebuggable- Returns:
- The debug information or null if there's nothing to log at this time.
-
getDatabaseState
TheIStorage.DatabaseStatethe database is in.- Specified by:
getDatabaseStatein interfaceIStorage- Returns:
- The
IStorage.DatabaseStatethe database is in.
-