From 48972e95238b39e38d1833a49fff126bba3ba4c4 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Mon, 14 Jul 2014 16:52:32 -0500 Subject: [PATCH] Schedule the time decrease for every ten seconds --- .../java/com/graywolf336/jail/JailTimer.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/JailTimer.java b/src/main/java/com/graywolf336/jail/JailTimer.java index c22ee3d..ebd9ad4 100644 --- a/src/main/java/com/graywolf336/jail/JailTimer.java +++ b/src/main/java/com/graywolf336/jail/JailTimer.java @@ -31,10 +31,10 @@ public class JailTimer { this.lastTime = System.currentTimeMillis(); if(pl.getConfig().getBoolean(Settings.USEBUKKITTIMER.getPath())) { 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 { pl.getLogger().info("Using the Java Timer."); - timer = new Timer(1000, new ActionListener () { + timer = new Timer(10000, new ActionListener () { public void actionPerformed (ActionEvent event) { pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new TimeEvent()); }; @@ -60,19 +60,8 @@ public class JailTimer { class TimeEvent implements Runnable { public void run() { - long timePassed; - - //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; - } + long timePassed = System.currentTimeMillis() - lastTime; + lastTime = System.currentTimeMillis(); for(Jail j : pl.getJailManager().getJails()) { for(Prisoner p : j.getAllPrisoners().values()) {