From 38655811b779ddb7cd15305808e76b16ecbb2959 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 6 Aug 2012 02:44:01 +0100 Subject: [PATCH] Don't bomb if userMap isn't initialized. --- .../src/com/earth2me/essentials/Essentials.java | 6 ++++++ .../com/earth2me/essentials/signs/SignGameMode.java | 9 +++++---- .../src/com/earth2me/essentials/signs/SignInfo.java | 12 ++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 1ac09bef8..92846124d 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -491,6 +491,12 @@ public class Essentials extends JavaPlugin implements IEssentials { return (User)base; } + + if (userMap == null) { + LOGGER.log(Level.WARNING, "Essentials userMap not initialized"); + return null; + } + User user = userMap.getUser(base.getName()); if (user == null) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java index 2f39a8a22..e3166db78 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java @@ -19,15 +19,15 @@ public class SignGameMode extends EssentialsSign @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException - { + { final String gamemode = sign.getLine(1); if (gamemode.isEmpty()) { sign.setLine(1, "Survival"); } - + validateTrade(sign, 2, ess); - + return true; } @@ -64,7 +64,8 @@ public class SignGameMode extends EssentialsSign { player.setGameMode(GameMode.ADVENTURE); } - else { + else + { throw new SignException(_("invalidSignLine", 2)); } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignInfo.java b/Essentials/src/com/earth2me/essentials/signs/SignInfo.java index 1d60ec127..e75b060e3 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignInfo.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignInfo.java @@ -20,7 +20,7 @@ public class SignInfo extends EssentialsSign @Override protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException - { + { validateTrade(sign, 3, ess); return true; } @@ -30,10 +30,10 @@ public class SignInfo extends EssentialsSign { final Trade charge = getTrade(sign, 3, ess); charge.isAffordableFor(player); - + String chapter = sign.getLine(1); String page = sign.getLine(2); - + final IText input; try { @@ -41,14 +41,14 @@ public class SignInfo extends EssentialsSign final IText output = new KeywordReplacer(input, player, ess); final TextPager pager = new TextPager(output); pager.showPage(chapter, page, null, player); - + } catch (IOException ex) { throw new SignException(ex.getMessage(), ex); } - - charge.charge(player); + + charge.charge(player); return true; } }