[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
This commit is contained in:
snowleo 2011-04-07 16:57:06 +00:00
parent 3908443717
commit 5dcb5e02fb

View file

@ -139,10 +139,13 @@ public class User extends PlayerExtension implements Comparable<User>, 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<User>, 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;
}