diff options
author | snowleo <schneeleo@gmail.com> | 2011-08-27 15:30:56 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-08-27 15:30:56 +0200 |
commit | 34987d6e07380c22bd643011ad48e9c8bc81c7cb (patch) | |
tree | 3828ac9d0dd2230d6fc5fd88aad45bd9c85ae22a | |
parent | 631583aef06fd00e41253a68b872b48f05c76eb9 (diff) | |
download | Essentials-34987d6e07380c22bd643011ad48e9c8bc81c7cb.tar Essentials-34987d6e07380c22bd643011ad48e9c8bc81c7cb.tar.gz Essentials-34987d6e07380c22bd643011ad48e9c8bc81c7cb.tar.lz Essentials-34987d6e07380c22bd643011ad48e9c8bc81c7cb.tar.xz Essentials-34987d6e07380c22bd643011ad48e9c8bc81c7cb.zip |
Fixes for afk
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 17 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/User.java | 4 | ||||
-rw-r--r-- | 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<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())); 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 ############################################################ # +------------------------------------------------------+ # |