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