Don't bomb if userMap isn't initialized.

This commit is contained in:
KHobbits 2012-08-06 02:44:01 +01:00
parent 2f562f79aa
commit 38655811b7
3 changed files with 17 additions and 10 deletions

View File

@ -491,6 +491,12 @@ public class Essentials extends JavaPlugin implements IEssentials
{ {
return (User)base; return (User)base;
} }
if (userMap == null) {
LOGGER.log(Level.WARNING, "Essentials userMap not initialized");
return null;
}
User user = userMap.getUser(base.getName()); User user = userMap.getUser(base.getName());
if (user == null) if (user == null)

View File

@ -19,15 +19,15 @@ public class SignGameMode extends EssentialsSign
@Override @Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{ {
final String gamemode = sign.getLine(1); final String gamemode = sign.getLine(1);
if (gamemode.isEmpty()) if (gamemode.isEmpty())
{ {
sign.setLine(1, "Survival"); sign.setLine(1, "Survival");
} }
validateTrade(sign, 2, ess); validateTrade(sign, 2, ess);
return true; return true;
} }
@ -64,7 +64,8 @@ public class SignGameMode extends EssentialsSign
{ {
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
} }
else { else
{
throw new SignException(_("invalidSignLine", 2)); throw new SignException(_("invalidSignLine", 2));
} }
} }

View File

@ -20,7 +20,7 @@ public class SignInfo extends EssentialsSign
@Override @Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{ {
validateTrade(sign, 3, ess); validateTrade(sign, 3, ess);
return true; return true;
} }
@ -30,10 +30,10 @@ public class SignInfo extends EssentialsSign
{ {
final Trade charge = getTrade(sign, 3, ess); final Trade charge = getTrade(sign, 3, ess);
charge.isAffordableFor(player); charge.isAffordableFor(player);
String chapter = sign.getLine(1); String chapter = sign.getLine(1);
String page = sign.getLine(2); String page = sign.getLine(2);
final IText input; final IText input;
try try
{ {
@ -41,14 +41,14 @@ public class SignInfo extends EssentialsSign
final IText output = new KeywordReplacer(input, player, ess); final IText output = new KeywordReplacer(input, player, ess);
final TextPager pager = new TextPager(output); final TextPager pager = new TextPager(output);
pager.showPage(chapter, page, null, player); pager.showPage(chapter, page, null, player);
} }
catch (IOException ex) catch (IOException ex)
{ {
throw new SignException(ex.getMessage(), ex); throw new SignException(ex.getMessage(), ex);
} }
charge.charge(player); charge.charge(player);
return true; return true;
} }
} }