package net.mc_pandacraft.java.plugin.pandacraftutils.modules; import java.util.Calendar; import java.util.Date; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import org.bukkit.scheduler.BukkitRunnable; public class SpawnTimeManager extends BukkitRunnable { private PandacraftUtils plugin; int timeTick = 0; private String initial_map_name = "spawn"; public SpawnTimeManager(PandacraftUtils pl) { plugin = pl; run(); plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1L, 2L); } @Override public void run() { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); int hours = calendar.get(Calendar.HOUR_OF_DAY); int minutes = calendar.get(Calendar.MINUTE); int seconds = calendar.get(Calendar.SECOND); timeTick = ((hours * 3600 + minutes * 60 + seconds) * 10 / 36) - 6000; if (timeTick < 0) timeTick += 24000; try { plugin.getServer().getWorld(initial_map_name).setFullTime(timeTick); } catch (NullPointerException e) {} } }