001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.backup;
020
021import com.plotsquared.core.player.PlotPlayer;
022import org.checkerframework.checker.nullness.qual.NonNull;
023import org.checkerframework.checker.nullness.qual.Nullable;
024
025import java.nio.file.Path;
026import java.util.List;
027import java.util.concurrent.CompletableFuture;
028
029public interface BackupProfile {
030
031    /**
032     * Asynchronously populate a list of available backups under this profile
033     *
034     * @return Future that will be completed with available backups
035     */
036    @NonNull CompletableFuture<List<Backup>> listBackups();
037
038    /**
039     * Remove all backups stored for this profile
040     */
041    void destroy();
042
043    /**
044     * Get the directory containing the backups for this profile.
045     * This directory may not actually exist.
046     *
047     * @return Folder that contains the backups for this profile
048     */
049    @NonNull Path getBackupDirectory();
050
051    /**
052     * Create a backup of the plot. If the profile is at the
053     * maximum backup capacity, the oldest backup will be deleted.
054     *
055     * @return Future that completes with the created backup.
056     */
057    @NonNull CompletableFuture<Backup> createBackup();
058
059    /**
060     * Restore a backup
061     *
062     * @param backup Backup to restore
063     * @param player The player restoring the backup
064     * @return Future that completes when the backup has finished
065     */
066    @NonNull CompletableFuture<Void> restoreBackup(final @NonNull Backup backup, @Nullable PlotPlayer<?> player);
067
068}