Interface UserPersistentStorage

All Known Implementing Classes:
SQLUserPersistentStorage

public interface UserPersistentStorage
Interface for user persistent storage
  • Method Details

    • getDatabaseName

      String getDatabaseName()
      Returns a prettified name of the database
      Returns:
      the database name
    • init

      void init() throws Exception
      Initializes the database (for example, connecting and creating necessary tables)
      Throws:
      Exception - if an error occurs
    • close

      void close() throws Exception
      Closes the database and the database connection
      Throws:
      Exception - if an error occurs
    • loadUser

      LifestealerUser loadUser(UUID uuid) throws Exception
      Loads a user from the database. This operation is blocking. Use LifestealerUserManager.getOrLoadUser(UUID) if you want to get the user if it is already loaded or load it from the database if it is not loaded.
      Parameters:
      uuid - the uuid of the user to load
      Returns:
      the loaded user or null if the user is not saved in the database
      Throws:
      Exception - if an error occurs while loading the user
    • loadAllUsers

      List<LifestealerUser> loadAllUsers() throws Exception
      Throws:
      Exception
    • saveUser

      void saveUser(LifestealerUser user) throws Exception
      Saves a user to the database. This operation is blocking. Use LifestealerUserManager.saveUserAsync(LifestealerUser) if you want to save the user asynchronously.
      Parameters:
      user - the user to save
      Throws:
      Exception - if an error occurs while saving the user
    • saveAllUsers

      void saveAllUsers(List<LifestealerUser> users) throws Exception
      Throws:
      Exception
    • deleteUser

      void deleteUser(LifestealerUser user) throws Exception
      Deletes a user from the database. This is used to delete a user from the database if they have no difference from the default values when saving through LifestealerUserManager
      Parameters:
      user - the user to delete
      Throws:
      Exception - if an error occurs while deleting the user