From 9f0aef8cecaf972d906673981a0f87591a09a745 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Mon, 27 Sep 2021 18:18:33 +0200 Subject: [PATCH] Hopefully fixes startup crashes --- .../bausystem/region/BackupScheduler.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index ffb6de3a..a132e920 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -20,6 +20,7 @@ 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; @@ -29,7 +30,10 @@ import org.bukkit.scheduler.BukkitRunnable; @Linked(LinkageType.ENABLE_LINK) -public class BackupScheduler implements Enable { +@Linked(LinkageType.DISABLE_LINK) +public class BackupScheduler implements Enable, Disable { + + private static final long PERIOD = 20 * 60 * 30; @Override public void enable() { @@ -39,7 +43,13 @@ public class BackupScheduler implements Enable { final Iterator regions = Region.getREGION_MAP().values().stream().filter(region -> region.get(Tag.CHANGED)).iterator(); BackupScheduler.this.doBackup(regions); } - }.runTaskTimer(BauSystem.getInstance(), 20, 20*60*30); + }.runTaskTimer(BauSystem.getInstance(), PERIOD, PERIOD); + } + + @Override + public void disable() { + final Iterator regions = Region.getREGION_MAP().values().stream().filter(region -> region.get(Tag.CHANGED)).iterator(); + BackupScheduler.this.doBackup(regions); } public void doBackup(final Iterator regionIterator) { @@ -56,6 +66,6 @@ public class BackupScheduler implements Enable { region.remove(Tag.CHANGED); } } - }.runTaskTimer(BauSystem.getInstance(), 0, 20); + }.runTaskTimer(BauSystem.getInstance(), 0, 100); } } \ No newline at end of file