Schedule the time decrease for every ten seconds

This commit is contained in:
graywolf336 2014-07-14 16:52:32 -05:00
parent fe7aabc6ea
commit 48972e9523

View File

@ -31,10 +31,10 @@ public class JailTimer {
this.lastTime = System.currentTimeMillis(); this.lastTime = System.currentTimeMillis();
if(pl.getConfig().getBoolean(Settings.USEBUKKITTIMER.getPath())) { if(pl.getConfig().getBoolean(Settings.USEBUKKITTIMER.getPath())) {
pl.getLogger().info("Using the Bukkit Scheduler."); pl.getLogger().info("Using the Bukkit Scheduler.");
pl.getServer().getScheduler().scheduleSyncRepeatingTask(pl, new TimeEvent(), 20, 20); pl.getServer().getScheduler().scheduleSyncRepeatingTask(pl, new TimeEvent(), 200, 200);
}else { }else {
pl.getLogger().info("Using the Java Timer."); pl.getLogger().info("Using the Java Timer.");
timer = new Timer(1000, new ActionListener () { timer = new Timer(10000, new ActionListener () {
public void actionPerformed (ActionEvent event) { public void actionPerformed (ActionEvent event) {
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new TimeEvent()); pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new TimeEvent());
}; };
@ -60,19 +60,8 @@ public class JailTimer {
class TimeEvent implements Runnable { class TimeEvent implements Runnable {
public void run() { public void run() {
long timePassed; long timePassed = System.currentTimeMillis() - lastTime;
lastTime = System.currentTimeMillis();
//Let's check if more than 10 seconds has passed since the
//last time we checked
if (System.currentTimeMillis() - lastTime >= 10000) {
//set the time passed to the current time minus the last time we checked
timePassed = System.currentTimeMillis() - lastTime;
lastTime = System.currentTimeMillis();
}else {
//Less than 10 seconds has past when we last ran this
//so let's wait till the next round before we do this
return;
}
for(Jail j : pl.getJailManager().getJails()) { for(Jail j : pl.getJailManager().getJails()) {
for(Prisoner p : j.getAllPrisoners().values()) { for(Prisoner p : j.getAllPrisoners().values()) {