When backup interval is set to zero, no automatic backups will be performed

This commit is contained in:
szymon 2020-07-14 14:41:59 +02:00
parent 55f5fdf1c4
commit d13bc5256c
2 changed files with 7 additions and 1 deletions

View File

@ -21,12 +21,15 @@ package net.szum123321.textile_backup;
import blue.endless.jankson.Comment;
import io.github.cottonmc.cotton.config.annotations.ConfigFile;
import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
@ConfigFile(name = TextileBackup.MOD_ID)
public class ConfigHandler {
@Comment("\nTime between automatic backups in seconds\n")
@Comment("\nTime between automatic backups in seconds\n" +
"When set to 0 backups will not be performed automatically\n")
public long backupInterval = 3600;
@Comment("\nShould backups be done even if there are no players?\n")

View File

@ -15,6 +15,9 @@ public class BackupScheduler {
}
public void tick(MinecraftServer server) {
if(TextileBackup.config.backupInterval <= 0)
return;
long now = Instant.now().getEpochSecond();
if(TextileBackup.config.doBackupsOnEmptyServer || server.getPlayerManager().getCurrentPlayerCount() > 0) {