diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-09 17:06:32 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-09 17:06:32 +0200 |
commit | 81994160e89c30aa870bc196e8ac38185e2b9974 (patch) | |
tree | 796398907042d8962508c88846c8e3efd565c715 | |
parent | cf59a90c520216c1504e87e7430e77a287132372 (diff) | |
download | Essentials-81994160e89c30aa870bc196e8ac38185e2b9974.tar Essentials-81994160e89c30aa870bc196e8ac38185e2b9974.tar.gz Essentials-81994160e89c30aa870bc196e8ac38185e2b9974.tar.lz Essentials-81994160e89c30aa870bc196e8ac38185e2b9974.tar.xz Essentials-81994160e89c30aa870bc196e8ac38185e2b9974.zip |
Allow players with essentials.signs.trade.override permission break invalid trade signs.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/SignTrade.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index bf85d827c..c19d19178 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -10,7 +10,6 @@ import org.bukkit.inventory.ItemStack; public class SignTrade extends EssentialsSign { - public SignTrade() { super("Trade"); @@ -40,11 +39,11 @@ public class SignTrade extends EssentialsSign substractAmount(sign, 1, stored, ess); stored.pay(player); Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess); - } + } catch (SignException e) { throw new SignException(Util.i18n("tradeSignEmptyOwner")); - } + } } else { @@ -67,11 +66,22 @@ public class SignTrade extends EssentialsSign if ((sign.getLine(3).length() > 3 && sign.getLine(3).substring(2).equalsIgnoreCase(username)) || player.isAuthorized("essentials.signs.trade.override")) { - final Trade stored1 = getTrade(sign, 1, true, false, ess); - final Trade stored2 = getTrade(sign, 2, true, false, ess); - stored1.pay(player); - stored2.pay(player); - Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess); + try + { + final Trade stored1 = getTrade(sign, 1, true, false, ess); + final Trade stored2 = getTrade(sign, 2, true, false, ess); + stored1.pay(player); + stored2.pay(player); + Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess); + } + catch (SignException e) + { + if (player.isAuthorized("essentials.signs.trade.override")) + { + return true; + } + throw e; + } return true; } else |