From 01cb4abb39c302736db73ee4a93ee7cba3bbd331 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 18 Sep 2022 13:32:15 +0200 Subject: [PATCH] Update BackupScheduler Signed-off-by: yoyosource --- .../bausystem/region/BackupScheduler.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index e9b7ac8f..ef60e2a1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -20,19 +20,19 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.Disable; import de.steamwar.bausystem.linkage.Enable; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.tags.Tag; -import java.util.Iterator; import org.bukkit.scheduler.BukkitRunnable; +import java.util.Iterator; + @Linked(LinkageType.ENABLE_LINK) -@Linked(LinkageType.DISABLE_LINK) -public class BackupScheduler implements Enable, Disable { +public class BackupScheduler implements Enable { + private static final long INITIAL = 20 * 60 * 5; private static final long PERIOD = 20 * 60 * 30; @Override @@ -43,15 +43,7 @@ public class BackupScheduler implements Enable, Disable { final Iterator regions = Region.getREGION_MAP().values().stream().filter(region -> region.get(Tag.CHANGED)).iterator(); BackupScheduler.this.doBackup(regions); } - }.runTaskTimer(BauSystem.getInstance(), PERIOD, PERIOD); - } - - @Override - public void disable() { - Region.getREGION_MAP().values().stream().filter(region -> region.get(Tag.CHANGED)).iterator().forEachRemaining(region -> { - region.backup(); - region.remove(Tag.CHANGED); - }); + }.runTaskTimer(BauSystem.getInstance(), INITIAL, PERIOD); } public void doBackup(final Iterator regionIterator) {