Interface SaveStorage

All Known Implementing Classes:
FileSaveStorage

public interface SaveStorage
SaveStorage defines the API for a storage mechanism for persisting game saves.
  • Field Details

  • Method Details

    • changeSaveDirectory

      void changeSaveDirectory(String path)
      Changes the directory in which saves are stored.
      Parameters:
      path - the path to where saves should be stored
    • load

      void load(String path, Consumer<String> onSuccess, Consumer<Exception> onFailure)
      Loads a save. The loaded save will be passed to the onSuccess callback.
      Parameters:
      path - the path to the save
      onSuccess - callback that is called when the save is loaded successfully
      onFailure - callback that is called when the save fails to load
    • load

      default void load(String path, Consumer<String> onSuccess)
      Loads a save. The loaded save will be passed to the onSuccess callback.
      Parameters:
      path - the path to the save
      onSuccess - callback that is called when the save is loaded successfully
    • save

      void save(String path, String content, Runnable onSuccess, Consumer<Exception> onFailure)
      Persists a save.
      Parameters:
      path - the path to the save
      content - the content of the save to be persisted
      onSuccess - callback that is called when the save is persisted successfully
      onFailure - callback that is called when the save fails to persist
    • save

      default void save(String path, String content, Runnable onSuccess)
      Persists a save.
      Parameters:
      path - the path to the save
      content - the content of the save to be persisted
      onSuccess - callback that is called when the save is persisted successfully
    • save

      default void save(String path, String content, Consumer<Exception> onFailure)
      Persists a save.
      Parameters:
      path - the path to the save
      content - the content of the save to be persisted
      onFailure - callback that is called when the save fails to persist
    • save

      default void save(String path, String content)
      Persists a save.
      Parameters:
      path - the path to the save
      content - the content of the save to be persisted
    • delete

      void delete(String path, Runnable onSuccess, Consumer<Exception> onFailure)
      Deletes a save.
      Parameters:
      path - the path to the save
      onSuccess - the callback that is called when the save is deleted successfully
      onFailure - the callback that is called when the save fails to delete
    • delete

      default void delete(String path, Runnable onSuccess)
      Deletes a save.
      Parameters:
      path - the path to the save
      onSuccess - the callback that is called when the save is deleted successfully
    • delete

      default void delete(String path)
      Deletes a save.
      Parameters:
      path - the path to the save
    • exists

      boolean exists(String path)
      Checks if a save exists.
      Parameters:
      path - the path to the save
      Returns:
      true if the save exists