diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java index e59df14..1e5fe59 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java @@ -101,10 +101,10 @@ public final class RedisBungee extends Plugin { for (Map.Entry entry : heartbeats.entrySet()) { try { long stamp = Long.parseLong(entry.getValue()); - if (System.currentTimeMillis() < stamp + 30000) + if (System.nanoTime() < stamp + TimeUnit.SECONDS.toNanos(30)) { servers.add(entry.getKey()); - else if (nag <= 0) { - getLogger().severe(entry.getKey() + " is " + (System.currentTimeMillis() - stamp) + "ms behind! (Time not synchronized or server down?)"); + } else if (nag <= 0) { + getLogger().severe(entry.getKey() + " is " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - stamp) + "ms behind! (Time not synchronized or server down?)"); } } catch (NumberFormatException ignored) { } @@ -247,7 +247,7 @@ public final class RedisBungee extends Plugin { public void run() { Jedis rsc = pool.getResource(); try { - rsc.hset("heartbeats", serverId, String.valueOf(System.currentTimeMillis())); + rsc.hset("heartbeats", serverId, String.valueOf(System.nanoTime())); } catch (JedisConnectionException e) { // Redis server has disappeared! getLogger().log(Level.SEVERE, "Unable to update heartbeat - did your Redis server go away?", e);