SteamWar/BauSystem2.0
Archiviert
12
0

Fix Region.backup size

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-07-10 17:46:30 +02:00
Ursprung be56f3caf8
Commit 859ddc0a3a
2 geänderte Dateien mit 8 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -28,7 +28,6 @@ import de.steamwar.bausystem.region.tags.Tag;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils; import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeMapper;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collections; import java.util.Collections;

Datei anzeigen

@ -466,6 +466,14 @@ public class Region {
final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name); final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name);
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
definedBackupFolder.mkdirs(); definedBackupFolder.mkdirs();
File[] currentBackups = definedBackupFolder.listFiles();
if (currentBackups.length >= 20) {
List<File> files = new ArrayList<>(Arrays.asList(currentBackups));
files.sort(Comparator.comparingLong(File::lastModified));
while (files.size() >= 20) files.remove(0).delete();
}
final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem"); final File backupFile = new File(definedBackupFolder, LocalDateTime.now().format(formatter) + ".schem");
//noinspection unchecked //noinspection unchecked
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, backupFile), 15)); return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, backupFile), 15));