From 5b975672e823e51f95efa2d847064a21ef1e0a29 Mon Sep 17 00:00:00 2001 From: snowleo Date: Fri, 8 Feb 2013 21:22:35 +0100 Subject: Don't overwrite last location on logout Logout position is saved as logoutlocation now in users yml --- .../src/com/earth2me/essentials/EssentialsPlayerListener.java | 5 +---- Essentials/src/com/earth2me/essentials/IUser.java | 2 ++ Essentials/src/com/earth2me/essentials/User.java | 6 ++++++ Essentials/src/com/earth2me/essentials/UserData.java | 11 +++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index c7b7b3201..a331b6378 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -138,10 +138,7 @@ public class EssentialsPlayerListener implements Listener { user.toggleVanished(); } - if (!user.isJailed()) - { - user.setLastLocation(); - } + user.setLogoutLocation(); if (user.isRecipeSee()) { user.getPlayer().getOpenInventory().getTopInventory().clear(); diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index 1b5f314be..5bc5f6373 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -48,4 +48,6 @@ public interface IUser extends Player boolean isAfk(); void setAfk(final boolean set); + + void setLogoutLocation(); } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 3a6b42781..5d5661646 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -253,6 +253,12 @@ public class User extends UserData implements Comparable, IReplyTo, IUser { setLastLocation(getLocation()); } + + @Override + public void setLogoutLocation() + { + setLogoutLocation(getLocation()); + } public void requestTeleport(final User player, final boolean here) { diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 930a9c913..6c963fb9b 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -318,6 +318,17 @@ public abstract class UserData extends PlayerExtension implements IConf config.setProperty("lastlocation", loc); config.save(); } + + public void setLogoutLocation(Location loc) + { + if (loc == null || loc.getWorld() == null) + { + return; + } + config.setProperty("logoutlocation", loc); + config.save(); + } + private long lastTeleportTimestamp; private long _getLastTeleportTimestamp() -- cgit v1.2.3