All Known Implementing Classes:
SQLiteJDBCDriverConnection

public interface IStorage
Represents storage of all structure related stuff.
  • Field Details

    • VALID_TABLE_NAME

      static final Pattern VALID_TABLE_NAME
  • Method Details

    • isValidTableName

      static boolean isValidTableName(String str)
      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

      boolean removeStructures(UUID playerUUID, String structureName)
      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

      boolean isAnimatedArchitectureWorld(String worldName)
      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

      int getStructureCountForPlayer(UUID playerUUID)
      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

      int getStructureCountForPlayer(UUID playerUUID, String structureName)
      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

      boolean updatePlayerData(PlayerData playerData)
      Updates the PlayerData for a given player.
      Parameters:
      playerData - The PlayerData the represents a player.
      Returns:
      True if at least 1 record was modified.
    • getPlayerData

      Optional<PlayerData> getPlayerData(UUID uuid)
      Tries to find the PlayerData for a player with the given UUID.
      Parameters:
      uuid - The UUID of a player.
      Returns:
      The PlayerData that represents the player.
    • getPlayerData

      List<PlayerData> getPlayerData(String playerName)
      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

      int getStructureCountByName(String structureName)
      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 - The Structure.
      Returns:
      The total number of owners of this structure.
    • getStructure

      Optional<Structure> 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.
      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

      Optional<Structure> getStructure(long structureUID)
      Gets the structure with the given structureUID and the original creator as StructureOwner;
      Parameters:
      structureUID - The UID of the structure to retrieve.
      Returns:
      The structure with the given structureUID and the original creator.
    • getStructures

      List<Structure> getStructures(UUID playerUUID, String name)
      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

      List<Structure> getStructures(UUID playerUUID)
      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

      List<Structure> getStructures(String name)
      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

      List<Structure> 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.
      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

      List<Structure> getStructures(UUID playerUUID, PermissionLevel maxPermission)
      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

      List<Structure> getStructuresOfType(String typeName)
      Obtains all structures of a given type.
      Parameters:
      typeName - The name of the type. See StructureType.getFullKey().
      Returns:
      All structures of the given type.
    • getStructuresOfType

      List<Structure> getStructuresOfType(String typeName, int version)
      Obtains all structures of a specific version of a given type.
      Parameters:
      typeName - The name of the type. See StructureType.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

      List<Structure> getStructuresInChunk(long chunkId)
      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

      Optional<Structure> insert(Structure structure)
      Inserts a new structure in the database. If the insertion was successful, a new Structure will be created with the correct structureUID.
      Parameters:
      structure - The structure to insert.
      Returns:
      The Structure that was just inserted if insertion was successful. This is NOT!! the same object as the one passed to this method.
    • syncStructureData

      boolean syncStructureData(IStructureConst structure)
      Synchronizes an Structure structure with the database. This will synchronize both the base and the type-specific data of the Structure.
      Parameters:
      structure - The IStructureConst that 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 all DatabaseManager.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

      boolean deleteStructureType(StructureType structureType)
      Deletes a StructureType and all Structures of this type from the database.

      Note that the StructureType has to be registered before it can be deleted! It doesn't need to be enabled, though.

      Parameters:
      structureType - The StructureType to delete.
      Returns:
      True if deletion was successful.
    • removeOwner

      boolean removeOwner(long structureUID, UUID playerUUID)
      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

      boolean addOwner(long structureUID, PlayerData player, PermissionLevel permission)
      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

      default long getFlag(IStructureConst structure)
      Gets the flag value of various boolean properties of a Structure.
      Parameters:
      structure - The Structure.
      Returns:
      The flag value of a Structure.
    • getDatabaseState

      IStorage.DatabaseState getDatabaseState()
      Obtains IStorage.DatabaseState the database is in.
      Returns:
      The IStorage.DatabaseState the database is in.