diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-09-22 20:43:27 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-09-22 20:43:27 +0100 |
commit | 9851b956a78065d746cc441424695a896cc8e7d4 (patch) | |
tree | 79f636cc44cfc60af4beda9df924396ce737ddf7 | |
parent | 5e8ecdd6f956bcf66cfe34b7a7a0b9e2fe1185b8 (diff) | |
download | Essentials-9851b956a78065d746cc441424695a896cc8e7d4.tar Essentials-9851b956a78065d746cc441424695a896cc8e7d4.tar.gz Essentials-9851b956a78065d746cc441424695a896cc8e7d4.tar.lz Essentials-9851b956a78065d746cc441424695a896cc8e7d4.tar.xz Essentials-9851b956a78065d746cc441424695a896cc8e7d4.zip |
Cleanup delhome to match normal home cases properly.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/UserData.java | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index be25cf665..e9b84e656 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -28,8 +28,9 @@ public abstract class UserData extends PlayerExtension implements IConf config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml")); reloadConfig(); } - - public final void reset () { + + public final void reset() + { config.getFile().delete(); config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml")); reloadConfig(); @@ -108,26 +109,25 @@ public abstract class UserData extends PlayerExtension implements IConf return new HashMap<String, Object>(); } - public Location getHome(String name) throws Exception + private String getHomeName(String search) { - Location loc = config.getLocation("homes." + name, getServer()); - if (loc == null) + if (Util.isInt(search)) { try { - loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer()); - } - catch (IndexOutOfBoundsException e) - { - return null; + search = getHomes().get(Integer.parseInt(search) - 1); } - catch (NumberFormatException e) + catch (Exception e) { - return null; } } - - return loc; + return search; + } + + public Location getHome(String name) throws Exception + { + String search = getHomeName(name); + return config.getLocation("homes." + search, getServer()); } public Location getHome(final Location world) @@ -169,20 +169,20 @@ public abstract class UserData extends PlayerExtension implements IConf public void delHome(String name) throws Exception { - String search = name; + String search = getHomeName(name); if (!homes.containsKey(search)) { - search = Util.sanitizeFileName(name); + search = Util.sanitizeFileName(search); } if (homes.containsKey(search)) { - homes.remove(name); - config.removeProperty("homes." + name); + homes.remove(search); + config.removeProperty("homes." + search); config.save(); } else { - throw new Exception(_("invalidHome", name)); + throw new Exception(_("invalidHome", search)); } } |