Interface IStorage
- All Known Implementing Classes:
SQLiteJDBCDriverConnection
public interface IStorage
Represents storage of all structure related stuff.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents the status of the database.static enumSet of bit flags to represent various properties of structures. -
Field Summary
Fields -
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.ObtainsIStorage.DatabaseStatethe database is in.default longgetFlag(IStructureConst structure) Gets the flag value of various boolean properties of aStructure.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.static booleanisValidTableName(String str) Checks if a specific String would make for a valid name for a table.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.
-
Field Details
-
VALID_TABLE_NAME
-
-
Method Details
-
isValidTableName
Checks if a specific String would make for a valid name for a table.- Parameters:
str- The String to check.- Returns:
- True if this String is valid as a table name.
-
removeStructure
boolean removeStructure(long structureUID) Delete the structure with the given structureUID from the database.- Parameters:
structureUID- The UID of the structure to delete.- Returns:
- True if at least 1 structure was successfully removed.
-
removeStructures
Delete all structures owned by the given player with the given name.- 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
Checks whether there are any structures in a given world.- Parameters:
worldName- The name of the world.- Returns:
- True if there are more than 0 structures in the given world.
-
getStructureCountForPlayer
Gets the total number of structures own by the given player.- Parameters:
playerUUID- The uuid of the player whose structures to count.- Returns:
- The total number of structures own by the given player.
-
getStructureCountForPlayer
Gets the number of structures own by the given player with the given name.- 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.
-
updatePlayerData
Updates thePlayerDatafor a given player.- Parameters:
playerData- ThePlayerDatathe represents a player.- Returns:
- True if at least 1 record was modified.
-
getPlayerData
Tries to find thePlayerDatafor a player with the givenUUID.- Parameters:
uuid- TheUUIDof a player.- Returns:
- The
PlayerDatathat represents the player.
-
getPlayerData
Tries 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
getPlayerData(UUID)instead.- Parameters:
playerName- The name of the player(s).- Returns:
- All the players with the given name.
-
getStructureCountByName
Gets the total number of structures with the given name regardless of who owns them.- Parameters:
structureName- The name of the structures to search for.- Returns:
- The total number of structures with the given name.
-
getOwnerCountOfStructure
int getOwnerCountOfStructure(long structureUID) Gets the total number of owners of a structure.- Parameters:
structureUID- TheStructure.- Returns:
- The total number of owners of this structure.
-
getStructure
Gets the structure with the given UID for the given player at the level of ownership this player has over the structure, if any.- 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.
-
getStructure
Gets the structure with the given structureUID and the original creator asStructureOwner;- Parameters:
structureUID- The UID of the structure to retrieve.- Returns:
- The structure with the given structureUID and the original creator.
-
getStructures
Gets all the structures owned by the given player with the given name.- 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
Gets all the structures owned by the given player.- Parameters:
playerUUID- The UUID of the player to search for.- Returns:
- All structures owned by the given player.
-
getStructures
Gets all the structures with the given name, regardless of who owns them.- 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
Gets all the structures with the given name, owned by the player with at least a certain permission level.- 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
Gets all the structures owned by a given player with at least a certain permission level.- 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.
-
getStructuresOfType
Obtains all structures of a given type.- Parameters:
typeName- The name of the type. SeeStructureType.getFullKey().- Returns:
- All structures of the given type.
-
getStructuresOfType
Obtains all structures of a specific version of a given type.- Parameters:
typeName- The name of the type. SeeStructureType.getFullKey().version- The version of the type.- Returns:
- All structures of the given type.
-
getPowerBlockData
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.The key is the hashed location in chunk space, the value is the list of UIDs of the structures whose powerblocks occupies that location.
- 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
Gets a list of structure UIDs that have their rotation point in a given chunk.- 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.
-
insert
Inserts a new structure in the database. If the insertion was successful, a newStructurewill be created with the correct structureUID.- Parameters:
structure- The structure to insert.- Returns:
- The
Structurethat was just inserted if insertion was successful. This is NOT!! the same object as the one passed to this method.
-
syncStructureData
Synchronizes anStructurestructure with the database. This will synchronize both the base and the type-specific data of theStructure.- Parameters:
structure- TheIStructureConstthat describes the data of structure.- Returns:
- True if the update was successful.
-
getPartialIdentifiers
List<DatabaseManager.StructureIdentifier> getPartialIdentifiers(String input, @Nullable @Nullable IPlayer player, PermissionLevel maxPermission, Collection<Property<?>> properties) Retrieves 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".
- 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.
-
deleteStructureType
Deletes 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.- Parameters:
structureType- TheStructureTypeto delete.- Returns:
- True if deletion was successful.
-
removeOwner
Removes an owner of a structure. Note that the original creator can never be removed.- 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
Adds 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.
- Parameters:
structureUID- The UID of the structure to modify.player- The player to add as owner.permission- The level of ownership the player will have over the structure.- Returns:
- True if the update was successful.
-
getFlag
Gets the flag value of various boolean properties of aStructure. -
getDatabaseState
IStorage.DatabaseState getDatabaseState()ObtainsIStorage.DatabaseStatethe database is in.- Returns:
- The
IStorage.DatabaseStatethe database is in.
-