[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
This commit is contained in:
snowleo 2011-05-01 21:58:38 +00:00
parent 224c18348a
commit 088508bd37
2 changed files with 21 additions and 12 deletions

View File

@ -193,7 +193,7 @@ public class EssentialsUpgrade
{
user.setMails(mails);
}
if (user.getHome() == null)
if (!user.hasHome())
{
@SuppressWarnings("unchecked")
List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");

View File

@ -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)