mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Destroy backups when the plot is uncalimed
This commit is contained in:
parent
e0c9a802d8
commit
658361f825
3 changed files with 15 additions and 6 deletions
|
@ -27,7 +27,6 @@ package com.plotsquared.core.backup;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -44,7 +43,7 @@ public interface BackupProfile {
|
|||
/**
|
||||
* Remove all backups stored for this profile
|
||||
*/
|
||||
void destroy() throws IOException;
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* Get the directory containing the backups for this profile.
|
||||
|
|
|
@ -102,10 +102,14 @@ public class PlayerBackupProfile implements BackupProfile {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void destroy() throws IOException {
|
||||
Files.delete(this.getBackupDirectory());
|
||||
// Invalidate backup cache
|
||||
this.backupCache = null;
|
||||
@Override public void destroy() {
|
||||
this.listBackups().whenCompleteAsync((backups, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
backups.forEach(Backup::delete);
|
||||
this.backupCache = null;
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull public Path getBackupDirectory() {
|
||||
|
|
|
@ -93,6 +93,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -1358,6 +1359,11 @@ public class Plot {
|
|||
for (PlotPlayer pp : players) {
|
||||
PlotListener.plotExit(pp, current);
|
||||
}
|
||||
|
||||
// Destroy all backups when the plot is unclaimed
|
||||
Objects.requireNonNull(PlotSquared.imp()).getBackupManager()
|
||||
.getProfile(current).destroy();
|
||||
|
||||
getArea().removePlot(getId());
|
||||
DBFunc.delete(current);
|
||||
current.setOwnerAbs(null);
|
||||
|
|
Loading…
Reference in a new issue