Fixes for afk

This commit is contained in:
snowleo 2011-08-27 15:30:56 +02:00
parent 631583aef0
commit 34987d6e07
3 changed files with 16 additions and 7 deletions

View File

@ -89,11 +89,17 @@ public class EssentialsPlayerListener extends PlayerListener
}
final User user = ess.getUser(event.getPlayer());
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
event.setCancelled(true);
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
final Location from = event.getFrom();
final Location to = event.getTo().clone();
to.setX(from.getX());
to.setY(from.getY());
to.setZ(from.getZ());
event.setTo(to);
return;
}
user.updateActivity();
if (!ess.getSettings().getNetherPortalsEnabled())
@ -478,6 +484,9 @@ public class EssentialsPlayerListener extends PlayerListener
}
}
}
user.updateActivity();
if (!cmd.equalsIgnoreCase("afk"))
{
user.updateActivity();
}
}
}

View File

@ -17,7 +17,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private transient User teleportRequester;
private transient boolean teleportRequestHere;
private transient final Teleport teleport;
private transient long lastOnlineActivity;
private transient long lastOnlineActivity = System.currentTimeMillis();;
private transient long lastActivity;
private boolean hidden = false;
private transient boolean godStateBeforeAfk;
@ -437,7 +437,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
}
final long autoafk = ess.getSettings().getAutoAfk();
if (autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
{
setAfk(true);
ess.broadcastMessage(getName(), Util.format("userIsAway", getDisplayName()));

View File

@ -250,7 +250,7 @@ auto-afk-kick: -1
# Other players or monsters can't push him out of afk mode then.
# This will also enable temporary god mode for the afk player.
# The player has to use the command /afk to leave the afk mode.
freeze-afk-player: false
freeze-afk-players: false
############################################################
# +------------------------------------------------------+ #