Fix Region.backup size
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
be56f3caf8
Commit
859ddc0a3a
@ -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;
|
||||||
|
@ -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));
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren