mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-07 19:40:23 +01:00
Don't return null, throw an exception
This commit is contained in:
parent
cfdb2a36c1
commit
3c98718387
@ -77,8 +77,17 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
|||||||
public User load(final String name) throws Exception
|
public User load(final String name) throws Exception
|
||||||
{
|
{
|
||||||
String sanitizedName = Util.sanitizeFileName(name);
|
String sanitizedName = Util.sanitizeFileName(name);
|
||||||
if (!sanitizedName.equals(name)) {
|
if (!sanitizedName.equals(name))
|
||||||
return getUser(sanitizedName);
|
{
|
||||||
|
User user = getUser(sanitizedName);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
throw new Exception("User not found!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (Player player : ess.getServer().getOnlinePlayers())
|
for (Player player : ess.getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -119,12 +128,12 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
|||||||
{
|
{
|
||||||
return keys.size();
|
return keys.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getUserFile(final String name)
|
public File getUserFile(final String name)
|
||||||
{
|
{
|
||||||
return getUserFile2(Util.sanitizeFileName(name));
|
return getUserFile2(Util.sanitizeFileName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getUserFile2(final String name)
|
private File getUserFile2(final String name)
|
||||||
{
|
{
|
||||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||||
|
Loading…
Reference in New Issue
Block a user