From a34c92d55a66339dd71275bb0e0da4bf69b6c4ed Mon Sep 17 00:00:00 2001 From: snowleo Date: Mon, 10 Oct 2011 00:27:55 +0200 Subject: Fix of the recharge code, also the maximum line length on signs is 15 not 16! --- .../src/com/earth2me/essentials/signs/SignTrade.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index 9ed5bb058..6c956165a 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -33,18 +33,22 @@ public class SignTrade extends EssentialsSign { if (sign.getLine(3).substring(2).equalsIgnoreCase(username)) { + final Trade store = rechargeSign(sign, ess, player); + Trade stored = null; try { - final Trade store = rechargeSign(sign, ess, player); - final Trade stored = getTrade(sign, 1, true, true, ess); + stored = getTrade(sign, 1, true, true, ess); substractAmount(sign, 1, stored, ess); stored.pay(player); - Trade.log("Sign", "Trade", "OwnerInteract", username, store, username, stored, sign.getBlock().getLocation(), ess); } catch (SignException e) { - throw new SignException(Util.i18n("tradeSignEmptyOwner"), e); + if (store == null) + { + throw new SignException(Util.i18n("tradeSignEmptyOwner"), e); + } } + Trade.log("Sign", "Trade", "OwnerInteract", username, store, username, stored, sign.getBlock().getLocation(), ess); } else { @@ -162,7 +166,7 @@ public class SignTrade extends EssentialsSign throw new SignException(Util.i18n("moreThanZero")); } String newline = amount + " " + split[1] + ":0"; - if ((newline + amount).length() > 16) + if ((newline + amount).length() > 15) { throw new SignException("Line can be too long!"); } @@ -272,7 +276,7 @@ public class SignTrade extends EssentialsSign if (money != null && amount != null) { final String newline = Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1); - if (newline.length() > 16) + if (newline.length() > 15) { throw new SignException("Line too long!"); } @@ -287,7 +291,7 @@ public class SignTrade extends EssentialsSign final ItemStack item = getItemStack(split[1], stackamount, ess); final int amount = getInteger(split[2]); final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value)); - if (newline.length() > 16) + if (newline.length() > 15) { throw new SignException("Line too long!"); } -- cgit v1.2.3