2015-01-22 09:32:47 +01:00
|
|
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
|
2014-11-22 17:18:10 +01:00
|
|
|
|
|
|
|
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 {
|
|
|
|
|
2015-01-24 09:18:11 +01:00
|
|
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
2014-11-22 17:18:10 +01:00
|
|
|
|
|
|
|
int timeTick = 0;
|
|
|
|
|
|
|
|
private String initial_map_name = "spawn";
|
|
|
|
|
|
|
|
|
2015-01-24 09:18:11 +01:00
|
|
|
public SpawnTimeManager() {
|
2014-11-22 17:18:10 +01:00
|
|
|
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) {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|