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.PlotSquared; 022import com.plotsquared.core.player.PlotPlayer; 023import com.plotsquared.core.plot.Plot; 024import org.checkerframework.checker.nullness.qual.NonNull; 025import org.checkerframework.checker.nullness.qual.Nullable; 026 027import java.nio.file.Path; 028import java.util.Objects; 029 030public interface BackupManager { 031 032 /** 033 * This will perform an automatic backup of the plot iff the plot has an owner, 034 * automatic backups are enabled. 035 * Otherwise it will complete immediately. 036 * 037 * @param player Player that triggered the backup 038 * @param plot Plot to perform the automatic backup on 039 * @param whenDone Action that runs when the automatic backup has been completed 040 */ 041 static void backup(@Nullable PlotPlayer<?> player, final @NonNull Plot plot, @NonNull Runnable whenDone) { 042 Objects.requireNonNull(PlotSquared.platform()).backupManager().automaticBackup(player, plot, whenDone); 043 } 044 045 /** 046 * Get the backup profile for a plot based on its 047 * current owner (if there is one) 048 * 049 * @param plot Plot to get the backup profile for 050 * @return Backup profile 051 */ 052 @NonNull BackupProfile getProfile(final @NonNull Plot plot); 053 054 /** 055 * This will perform an automatic backup of the plot iff the plot has an owner, 056 * automatic backups are enabled. 057 * Otherwise it will complete immediately. 058 * 059 * @param player Player that triggered the backup 060 * @param plot Plot to perform the automatic backup on 061 * @param whenDone Action that runs when the automatic backup has been completed 062 */ 063 void automaticBackup(@Nullable PlotPlayer<?> player, final @NonNull Plot plot, @NonNull Runnable whenDone); 064 065 /** 066 * Get the directory in which backups are stored 067 * 068 * @return Backup directory path 069 */ 070 @NonNull Path getBackupPath(); 071 072 /** 073 * Get the maximum amount of backups that may be stored for 074 * a plot-owner combo 075 * 076 * @return Backup limit 077 */ 078 int getBackupLimit(); 079 080 /** 081 * Returns true if (potentially) destructive actions should cause 082 * PlotSquared to create automatic plot backups 083 * 084 * @return {@code true} if automatic backups are enabled 085 */ 086 boolean shouldAutomaticallyBackup(); 087 088}