From 088508bd374b630e75b4ea9364bfbdaae1a30586 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 1 May 2011 21:58:38 +0000 Subject: [PATCH] [trunk] Fix bug on upgrade the home locations git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1301 e251c2fe-e539-e718-e476-b85c1f46cddb --- .../essentials/EssentialsUpgrade.java | 2 +- .../src/com/earth2me/essentials/UserData.java | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java index cba23d301..8f582769e 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -193,7 +193,7 @@ public class EssentialsUpgrade { user.setMails(mails); } - if (user.getHome() == null) + if (!user.hasHome()) { @SuppressWarnings("unchecked") List vals = (List)usersConfig.getProperty(username + ".home"); diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 941950c4e..170394014 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -87,21 +87,30 @@ public abstract class UserData extends PlayerExtension implements IConf } } - public Location getHome() + public boolean hasHome() { if (config.hasProperty("home")) { - World world = getLocation().getWorld(); - String worldHome = "home.worlds." + world.getName().toLowerCase(); - if (!config.hasProperty(worldHome)) - { - String defaultWorld = config.getString("home.default"); - worldHome = "home.worlds." + defaultWorld; - } - Location loc = config.getLocation(worldHome, getServer()); - return loc; + return true; } - return null; + return false; + } + + public Location getHome() + { + if (!hasHome()) + { + return null; + } + World world = getLocation().getWorld(); + String worldHome = "home.worlds." + world.getName().toLowerCase(); + if (!config.hasProperty(worldHome)) + { + String defaultWorld = config.getString("home.default"); + worldHome = "home.worlds." + defaultWorld; + } + Location loc = config.getLocation(worldHome, getServer()); + return loc; } public void setHome(Location loc, boolean b)