diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-04-30 00:03:59 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-04-30 00:07:28 +0100 |
commit | a6c55a1d9eebadc7a367ed0c6295ad9446be206e (patch) | |
tree | 45a47ced59d803ed018da763e430fdce16520409 | |
parent | 57d6fb12b512cc7e9929e01c2cdff3672eeeb08d (diff) | |
download | Essentials-a6c55a1d9eebadc7a367ed0c6295ad9446be206e.tar Essentials-a6c55a1d9eebadc7a367ed0c6295ad9446be206e.tar.gz Essentials-a6c55a1d9eebadc7a367ed0c6295ad9446be206e.tar.lz Essentials-a6c55a1d9eebadc7a367ed0c6295ad9446be206e.tar.xz Essentials-a6c55a1d9eebadc7a367ed0c6295ad9446be206e.zip |
Fix Eco take bug and fix NPE
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandeco.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java index 16cbdbcc3..c3c64b904 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java @@ -19,11 +19,11 @@ public class Commandeco extends EssentialsCommand @Override public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - if (args.length < 2) { throw new NotEnoughArgumentsException(); } + Commandeco.EcoCommands cmd; double startingBalance = (double)ess.getSettings().getStartingBalance(); double amount; @@ -115,7 +115,7 @@ public class Commandeco extends EssentialsCommand } } - private void take(double amount, final User player, final CommandSender sender) + private void take(double amount, final User player, final CommandSender sender) throws Exception { double money = player.getMoney(); double minBalance = ess.getSettings().getMinMoney(); @@ -123,11 +123,14 @@ public class Commandeco extends EssentialsCommand { player.takeMoney(amount, sender); } - else + else if (sender == null) { - player.sendMessage(_("takenFromAccount", Util.displayCurrency(money - minBalance, ess))); - sender.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(money - minBalance, ess), player.getDisplayName(), Util.displayCurrency(player.getMoney(), ess))); player.setMoney(minBalance); + player.sendMessage(_("takenFromAccount", Util.displayCurrency(money - minBalance, ess))); + } + else + { + throw new Exception(_("notEnoughMoney")); } } |