Make sure we don't bounce people with expired tempbans.

This commit is contained in:
KHobbits 2011-09-26 23:37:00 +01:00
parent 8b23f8608d
commit 8e0560ae1a
2 changed files with 17 additions and 8 deletions

View file

@ -108,7 +108,8 @@ public class EssentialsPlayerListener extends PlayerListener
}
Location afk = user.getAfkPosition();
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) {
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
{
user.updateActivity(true);
}
@ -314,14 +315,13 @@ public class EssentialsPlayerListener extends PlayerListener
user.setNPC(false);
final long currentTime = System.currentTimeMillis();
user.checkBanTimeout(currentTime);
boolean banExpired = user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
if (user.isBanned() || event.getResult() == Result.KICK_BANNED)
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
{
final String banReason = user.getBanReason();
LOGGER.log(Level.INFO, "Banned for '" + banReason + "'");
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : Util.i18n("defaultBanReason"));
return;
}

View file

@ -381,7 +381,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.hidden = hidden;
}
public void checkJailTimeout(final long currentTime)
//Returns true if status expired during this check
public boolean checkJailTimeout(final long currentTime)
{
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
{
@ -396,26 +397,34 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
catch (Exception ex)
{
}
return true;
}
return false;
}
public void checkMuteTimeout(final long currentTime)
//Returns true if status expired during this check
public boolean checkMuteTimeout(final long currentTime)
{
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
{
setMuteTimeout(0);
sendMessage(Util.i18n("canTalkAgain"));
setMuted(false);
return true;
}
return false;
}
public void checkBanTimeout(final long currentTime)
//Returns true if status expired during this check
public boolean checkBanTimeout(final long currentTime)
{
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
{
setBanTimeout(0);
setBanned(false);
return true;
}
return false;
}
public void updateActivity(final boolean broadcast)