summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-02-11 21:15:26 +0000
committerKHobbits <rob@khobbits.co.uk>2012-02-11 21:15:26 +0000
commitc6a96bc7a3c410ad3747bfb00a0ca4e1c85dd4fa (patch)
tree9ddfee3b55c8a92a6da5040283a651d5d60a5149
parent303ddc81195966541b44c1f26ff87fb531a6eab5 (diff)
downloadEssentials-c6a96bc7a3c410ad3747bfb00a0ca4e1c85dd4fa.tar
Essentials-c6a96bc7a3c410ad3747bfb00a0ca4e1c85dd4fa.tar.gz
Essentials-c6a96bc7a3c410ad3747bfb00a0ca4e1c85dd4fa.tar.lz
Essentials-c6a96bc7a3c410ad3747bfb00a0ca4e1c85dd4fa.tar.xz
Essentials-c6a96bc7a3c410ad3747bfb00a0ca4e1c85dd4fa.zip
Update trade signs properly, and visibly handle full signs.
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignTrade.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java
index 943a14a83..6b47ebc76 100644
--- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java
+++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java
@@ -36,7 +36,7 @@ public class SignTrade extends EssentialsSign
try
{
stored = getTrade(sign, 1, true, true, ess);
- substractAmount(sign, 1, stored, ess);
+ subtractAmount(sign, 1, stored, ess);
stored.pay(player);
}
catch (SignException e)
@@ -53,12 +53,14 @@ public class SignTrade extends EssentialsSign
final Trade charge = getTrade(sign, 1, false, false, ess);
final Trade trade = getTrade(sign, 2, false, true, ess);
charge.isAffordableFor(player);
+ addAmount(sign, 1, charge, ess);
+ subtractAmount(sign, 2, trade, ess);
if (!trade.pay(player, false))
{
+ subtractAmount(sign, 1, charge, ess);
+ addAmount(sign, 2, trade, ess);
throw new ChargeException("Full inventory");
}
- substractAmount(sign, 2, trade, ess);
- addAmount(sign, 1, charge, ess);
charge.charge(player);
Trade.log("Sign", "Trade", "Interact", sign.getLine(3), charge, username, trade, sign.getBlock().getLocation(), ess);
}
@@ -256,7 +258,7 @@ public class SignTrade extends EssentialsSign
throw new SignException(_("invalidSignLine", index + 1));
}
- protected final void substractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException
+ protected final void subtractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException
{
final Double money = trade.getMoney();
if (money != null)
@@ -294,6 +296,7 @@ public class SignTrade extends EssentialsSign
}
}
+ //TODO: Translate these exceptions.
private void changeAmount(final ISign sign, final int index, final double value, final IEssentials ess) throws SignException
{
@@ -313,7 +316,7 @@ public class SignTrade extends EssentialsSign
final String newline = Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1);
if (newline.length() > 15)
{
- throw new SignException("Line too long!");
+ throw new SignException("This sign is full: Line too long!");
}
sign.setLine(index, newline);
return;
@@ -329,7 +332,7 @@ public class SignTrade extends EssentialsSign
final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value));
if (newline.length() > 15)
{
- throw new SignException("Line too long!");
+ throw new SignException("This sign is full: Line too long!");
}
sign.setLine(index, newline);
return;
@@ -343,7 +346,7 @@ public class SignTrade extends EssentialsSign
final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value));
if (newline.length() > 15)
{
- throw new SignException("Line too long!");
+ throw new SignException("This sign is full: Line too long!");
}
sign.setLine(index, newline);
return;