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 | da01bdc2b0c0b8c39a436f3fbca45ef9501fbfb7 (patch) | |
tree | 582fabeccc0397f6ce8bd7c28f386808870fe4e6 | |
parent | 80a96e2a731d446a7018cc1d3fef6c64b8527e26 (diff) | |
download | Essentials-da01bdc2b0c0b8c39a436f3fbca45ef9501fbfb7.tar Essentials-da01bdc2b0c0b8c39a436f3fbca45ef9501fbfb7.tar.gz Essentials-da01bdc2b0c0b8c39a436f3fbca45ef9501fbfb7.tar.lz Essentials-da01bdc2b0c0b8c39a436f3fbca45ef9501fbfb7.tar.xz Essentials-da01bdc2b0c0b8c39a436f3fbca45ef9501fbfb7.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)); } } |