package space.gatt.magicaproject.managers;

import org.bukkit.Bukkit;
import space.gatt.magicaproject.MagicaMain;
import space.gatt.magicaproject.objects.MagicaBlock;

import java.util.ArrayList;
import java.util.List;

public class BlockManager {

	private List<MagicaBlock> runningBlocks = new ArrayList<>();

	public BlockManager() {
		Bukkit.getScheduler().runTaskTimer(MagicaMain.getMagicaMain(), ()->{
			for (MagicaBlock mb : runningBlocks){
				mb.runParticles();
			}
		}, 10, 10);
	}

	public void registerBlock(MagicaBlock mb){
		if (!runningBlocks.contains(mb)){
			runningBlocks.add(mb);
		}
	}
}

@@ -107,16 +107,70 @@
 caMain;%0A
+import space.gatt.magicaproject.objects.MagicCrafter;%0A
 import s
@@ -654,11 +654,156 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09public void shutdown()%7B%0A%09%09for (MagicaBlock mb : runningBlocks)%7B%0A%09%09%09if (mb instanceof Saveable)%7B%0A%09%09%09%09((Saveable)mb).shutdownCall();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Call for all blocks to save