From 5dcb5e02fb19040986eea8cb09604ba941cf30af Mon Sep 17 00:00:00 2001 From: snowleo Date: Thu, 7 Apr 2011 16:57:06 +0000 Subject: [PATCH] [trunk] Last heal, Last teleport: Don't error if it's the first time. git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1144 e251c2fe-e539-e718-e476-b85c1f46cddb --- .../src/com/earth2me/essentials/User.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 1b14c7be5..b4c1fb452 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -139,10 +139,13 @@ public class User extends PlayerExtension implements Comparable, IReplyTo public void teleportCooldown(boolean justCheck) throws Exception { long now = Calendar.getInstance().getTimeInMillis(); - long cooldown = Essentials.getSettings().getTeleportCooldown(); - long left = lastTeleport + cooldown - now; - if (left > 0 && !isOp() && !isAuthorized("essentials.teleport.cooldown.bypass")) - throw new Exception("Time before next teleport: " + Essentials.FormatTime(left)); + if (lastTeleport > 0) { + long cooldown = Essentials.getSettings().getTeleportCooldown(); + long left = lastTeleport + cooldown - now; + if (left > 0 && !isOp() && !isAuthorized("essentials.teleport.cooldown.bypass")) { + throw new Exception("Time before next teleport: " + Essentials.FormatTime(left)); + } + } // if justCheck is set, don't update lastTeleport; we're just checking if (!justCheck) lastTeleport = now; } @@ -155,10 +158,13 @@ public class User extends PlayerExtension implements Comparable, IReplyTo public void healCooldown() throws Exception { long now = Calendar.getInstance().getTimeInMillis(); - long cooldown = Essentials.getSettings().getHealCooldown(); - long left = lastHeal + cooldown - now; - if (left > 0 && !isOp() && !isAuthorized("essentials.heal.cooldown.bypass")) - throw new Exception("Time before next heal: " + Essentials.FormatTime(left)); + if (lastHeal > 0) { + long cooldown = Essentials.getSettings().getHealCooldown(); + long left = lastHeal + cooldown - now; + if (left > 0 && !isOp() && !isAuthorized("essentials.heal.cooldown.bypass")) { + throw new Exception("Time before next heal: " + Essentials.FormatTime(left)); + } + } lastHeal = now; }