package net.sourceforge.pain; import net.sourceforge.pain.util.*; import java.io.*; public class WorldSaver implements TimeListener { public static final int FLUSH_PERIOD = 20;// in seconds public int flushingPeriodInTicks = FLUSH_PERIOD * net.sourceforge.pain.Time.PULSE_PER_SCD; public int flushTime = flushingPeriodInTicks; public WorldSaver() { } public void pulse(int time) { // Log.debug(time+"/"+flushTime); if (flushTime <= time) { Log.debug("saving world!"); try { Core.getDB().flush(); } catch (IOException e) { Log.error(e); } Log.debug("saved"); flushTime = time + flushingPeriodInTicks; } } }