From 3c98718387cf8c612e11f00df216c9ffb268568e Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 14 Feb 2012 20:29:45 +0100 Subject: [PATCH] Don't return null, throw an exception --- .../src/com/earth2me/essentials/UserMap.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java index f15e5edd9..94b504241 100644 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ b/Essentials/src/com/earth2me/essentials/UserMap.java @@ -77,8 +77,17 @@ public class UserMap extends CacheLoader implements IConf public User load(final String name) throws Exception { String sanitizedName = Util.sanitizeFileName(name); - if (!sanitizedName.equals(name)) { - return getUser(sanitizedName); + if (!sanitizedName.equals(name)) + { + User user = getUser(sanitizedName); + if (user == null) + { + throw new Exception("User not found!"); + } + else + { + return user; + } } for (Player player : ess.getServer().getOnlinePlayers()) { @@ -119,12 +128,12 @@ public class UserMap extends CacheLoader implements IConf { return keys.size(); } - + public File getUserFile(final String name) { return getUserFile2(Util.sanitizeFileName(name)); } - + private File getUserFile2(final String name) { final File userFolder = new File(ess.getDataFolder(), "userdata");