From 34987d6e07380c22bd643011ad48e9c8bc81c7cb Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 27 Aug 2011 15:30:56 +0200 Subject: Fixes for afk --- .../earth2me/essentials/EssentialsPlayerListener.java | 17 +++++++++++++---- Essentials/src/com/earth2me/essentials/User.java | 4 ++-- Essentials/src/config.yml | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index ffdefb663..e6a7f3d3d 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -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(); + } } } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 722cfadb1..3af6a5a4e 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -17,7 +17,7 @@ public class User extends UserData implements Comparable, 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, 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())); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 6f4447f2b..6884960c1 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -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 ############################################################ # +------------------------------------------------------+ # -- cgit v1.2.3