From d13bc5256c3e18a66cd7ebcf6ecf3658de593893 Mon Sep 17 00:00:00 2001 From: szymon Date: Tue, 14 Jul 2020 14:41:59 +0200 Subject: [PATCH] When backup interval is set to zero, no automatic backups will be performed --- .../java/net/szum123321/textile_backup/ConfigHandler.java | 5 ++++- .../net/szum123321/textile_backup/core/BackupScheduler.java | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/szum123321/textile_backup/ConfigHandler.java b/src/main/java/net/szum123321/textile_backup/ConfigHandler.java index 9b17cfe..45a9b75 100644 --- a/src/main/java/net/szum123321/textile_backup/ConfigHandler.java +++ b/src/main/java/net/szum123321/textile_backup/ConfigHandler.java @@ -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") diff --git a/src/main/java/net/szum123321/textile_backup/core/BackupScheduler.java b/src/main/java/net/szum123321/textile_backup/core/BackupScheduler.java index 0dd6698..46da9eb 100644 --- a/src/main/java/net/szum123321/textile_backup/core/BackupScheduler.java +++ b/src/main/java/net/szum123321/textile_backup/core/BackupScheduler.java @@ -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) {