Fixing trade message to be more user friendly.

This commit is contained in:
KHobbits 2011-08-20 21:58:26 +01:00
parent 69b76b810c
commit 83fc7de01a
7 changed files with 34 additions and 13 deletions

View file

@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack;
public class SignTrade extends EssentialsSign
{
public SignTrade()
{
super("Trade");
@ -33,10 +34,17 @@ public class SignTrade extends EssentialsSign
{
if (sign.getLine(3).substring(2).equalsIgnoreCase(username))
{
final Trade stored = getTrade(sign, 1, true, true, ess);
substractAmount(sign, 1, stored, ess);
stored.pay(player);
Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess);
try
{
final Trade stored = getTrade(sign, 1, true, true, ess);
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
{
@ -141,7 +149,7 @@ public class SignTrade extends EssentialsSign
sign.setLine(index, stackamount + " " + split[1] + ":" + amount);
return;
}
throw new SignException(Util.format("invalidSignLine", index+1));
throw new SignException(Util.format("invalidSignLine", index + 1));
}
protected final Trade getTrade(final ISign sign, final int index, final boolean fullAmount, final boolean notEmpty, final IEssentials ess) throws SignException
@ -155,11 +163,18 @@ public class SignTrade extends EssentialsSign
if (split.length == 2)
{
final Double money = getMoney(split[0]);
final Double amount = notEmpty ? getDoublePositive(split[1]) : getDouble(split[1]);
if (money != null && amount != null)
try
{
return new Trade(fullAmount ? amount : money, ess);
final Double money = getMoney(split[0]);
final Double amount = notEmpty ? getDoublePositive(split[1]) : getDouble(split[1]);
if (money != null && amount != null)
{
return new Trade(fullAmount ? amount : money, ess);
}
}
catch (SignException e)
{
throw new SignException(Util.i18n("tradeSignEmpty"));
}
}
@ -171,12 +186,12 @@ public class SignTrade extends EssentialsSign
amount -= amount % stackamount;
if (notEmpty && (amount < 1 || stackamount < 1 || item.getTypeId() == 0))
{
throw new SignException(Util.i18n("moreThanZero"));
throw new SignException(Util.i18n("tradeSignEmpty"));
}
item.setAmount(fullAmount ? amount : stackamount);
return new Trade(item, ess);
}
throw new SignException(Util.format("invalidSignLine", index+1));
throw new SignException(Util.format("invalidSignLine", index + 1));
}
protected final void substractAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException
@ -235,6 +250,6 @@ public class SignTrade extends EssentialsSign
sign.setLine(index, stackamount + " " + split[1] + ":" + (amount + Math.round(value)));
return;
}
throw new SignException(Util.format("invalidSignLine", index+1));
throw new SignException(Util.format("invalidSignLine", index + 1));
}
}

View file

@ -291,7 +291,8 @@ timeSetPermission = \u00a7cYou are not authorized to set the time.
timeWorldCurrent = The current time in {0} is \u00a73{1}
timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Trade completed.
tradeSignEmpty = The trade sign does not have enough supply left.
tradeSignEmpty = The trade sign has nothing available for you.
tradeSignEmptyOwner = There is nothing to collect from this trade sign.
treeFailure = \u00a7cTree generation failure. Try again on grass or dirt.
treeSpawned = \u00a77Tree spawned.
typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77.

View file

@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1}
timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Forhandling fuldf\u00f8rt.
tradeSignEmpty = Forhandlings skiltet har ikke nok forsyning tilbage.
tradeSignEmptyOwner = There is nothing to collect from this trade sign.
treeFailure = \u00a7cTr\u00e6 genererings fejl. Pr\u00f8v igen p\u00e5 gr\u00e6s eller jord.
treeSpawned = \u00a77Tr\u00e6 fremkaldt.
typeTpaccept = \u00a77For at teleportere, skriv \u00a7c/tpaccept\u00a77.

View file

@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1}
timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Handel abgeschlossen.
tradeSignEmpty = Der Bestand des Trade-Schild ist aufgebraucht.
tradeSignEmptyOwner = There is nothing to collect from this trade sign.
treeFailure = \u00a7cBaumpflanzung gescheitert. Versuche es auf Gras oder Dreck.
treeSpawned = \u00a77Baum gepflanzt.
typeTpaccept = \u00a77Um zu teleportieren, schreibe \u00a7c/tpaccept\u00a77.

View file

@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1}
timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Trade completed.
tradeSignEmpty = The trade sign does not have enough supply left.
tradeSignEmptyOwner = There is nothing to collect from this trade sign.
treeFailure = \u00a7cTree generation failure. Try again on grass or dirt.
treeSpawned = \u00a77Tree spawned.
typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77.

View file

@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1}
timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77\u00c9change termin\u00e9.
tradeSignEmpty = Le panneau de vente n''as pas encore assez de stock.
tradeSignEmptyOwner = There is nothing to collect from this trade sign.
treeFailure = \u00a7cEchec de la g\u00e9n\u00e9ration de l''arbre. Essayez de nouveau sur de l''herbe ou de la terre.
treeSpawned = \u00a77Arbre cr\u00e9\u00e9.
typeTpaccept = \u00a77Pour le t\u00e9l\u00e9porter, tapez \u00a7c/tpaccept\u00a77.

View file

@ -292,6 +292,7 @@ timeWorldCurrent = The current time in {0} is \u00a73{1}
timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Ruil verricht.
tradeSignEmpty = Het handelsbordje heeft een te kleine voorraad.
tradeSignEmptyOwner = There is nothing to collect from this trade sign.
treeFailure = \u00a7cFout bij het genereren van boom. Pobeer het opnieuw op gras of dirt.
treeSpawned = \u00a77Boom gespawned.
typeTpaccept = \u00a77Om te teleporten, type \u00a7c/tpaccept\u00a77.