package vg.civcraft.mc.civmodcore.world.locations.chunkmeta.api;

import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import vg.civcraft.mc.civmodcore.world.locations.global.GlobalLocationTracker;
import vg.civcraft.mc.civmodcore.world.locations.global.LocationTrackable;

public class SingleBlockAPIView <T extends LocationTrackable> extends APIView {

	private final GlobalLocationTracker<T> tracker;
	
	SingleBlockAPIView(JavaPlugin plugin, short pluginID, GlobalLocationTracker<T> tracker) {
		super(plugin, pluginID);
		this.tracker = tracker;
		Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, tracker::initFromDB);
	}
	
	public T get(Location loc) {
		return tracker.get(loc);
	}

	public void put(T trackable) {
		tracker.put(trackable);
	}

	public T remove(Location loc) {
		return tracker.remove(loc);
	}

	public T remove(T trackable) {
		return remove(trackable.getLocation());
	}

	public void handleChunkLoad(Chunk chunk) {

	}

	public void handleChunkUnload(Chunk chunk) {

	}

	@Override
	public void disable() {
		tracker.persist();
	}

}

@@ -339,359 +339,1028 @@
 e;%0A%0A
-public class SingleBlockAPIView %3CT extends LocationTrackable%3E extends APIView %7B%0A%0A%09private final GlobalLocationTracker%3CT%3E tracker;%0A%09%0A%09SingleBlockAPIView(JavaPlugin plugin, short pluginID, GlobalLocationTracker%3CT%3E tracker) %7B%0A%09%09super(plugin, pluginID);%0A%09%09this.tracker = tracker;%0A%09%09Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, tracker::initFromDB
+import java.util.concurrent.Executors;%0Aimport java.util.concurrent.ScheduledExecutorService;%0Aimport java.util.concurrent.ScheduledFuture;%0Aimport java.util.concurrent.TimeUnit;%0A%0Apublic class SingleBlockAPIView %3CT extends LocationTrackable%3E extends APIView %7B%0A%0A%09private static final long REGULAR_SAVE_INTERVAL_MILLISECONDS = 60L * 1000L;%0A%0A%09private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);%0A%09private final GlobalLocationTracker%3CT%3E tracker;%0A%09private ScheduledFuture%3C?%3E regularSaveRunnable;%0A%09%0A%09SingleBlockAPIView(JavaPlugin plugin, short pluginID, GlobalLocationTracker%3CT%3E tracker) %7B%0A%09%09super(plugin, pluginID);%0A%09%09this.tracker = tracker;%0A%09%09Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, tracker::initFromDB);%0A%09%09registerRegularSaveRunnable();%0A%09%7D%0A%0A%09private void registerRegularSaveRunnable() %7B%0A%09%09this.regularSaveRunnable = scheduler.scheduleWithFixedDelay(() -%3E %7B%0A%09%09%09tracker.persist();%0A%09%09%7D, REGULAR_SAVE_INTERVAL_MILLISECONDS, REGULAR_SAVE_INTERVAL_MILLISECONDS, TimeUnit.MILLISECONDS
 );%0A%09
@@ -1763,24 +1763,108 @@
 disable() %7B%0A
+%09%09if (this.regularSaveRunnable != null)%0A%09%09%09this.regularSaveRunnable.cancel(false);%0A%0A
 %09%09tracker.pe

Add scheduled task to save regular changes for SingleBlockAPIView used in JukeAlert