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 class SignTrade extends EssentialsSign
{ {
public SignTrade() public SignTrade()
{ {
super("Trade"); super("Trade");
@ -32,12 +33,19 @@ public class SignTrade extends EssentialsSign
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
{ {
if (sign.getLine(3).substring(2).equalsIgnoreCase(username)) if (sign.getLine(3).substring(2).equalsIgnoreCase(username))
{
try
{ {
final Trade stored = getTrade(sign, 1, true, true, ess); final Trade stored = getTrade(sign, 1, true, true, ess);
substractAmount(sign, 1, stored, ess); substractAmount(sign, 1, stored, ess);
stored.pay(player); stored.pay(player);
Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess); Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess);
} }
catch (SignException e)
{
throw new SignException(Util.i18n("tradeSignEmptyOwner"));
}
}
else else
{ {
final Trade charge = getTrade(sign, 1, false, false, ess); final Trade charge = getTrade(sign, 1, false, false, ess);
@ -154,6 +162,8 @@ public class SignTrade extends EssentialsSign
final String[] split = line.split("[ :]+"); final String[] split = line.split("[ :]+");
if (split.length == 2) if (split.length == 2)
{
try
{ {
final Double money = getMoney(split[0]); final Double money = getMoney(split[0]);
final Double amount = notEmpty ? getDoublePositive(split[1]) : getDouble(split[1]); final Double amount = notEmpty ? getDoublePositive(split[1]) : getDouble(split[1]);
@ -162,6 +172,11 @@ public class SignTrade extends EssentialsSign
return new Trade(fullAmount ? amount : money, ess); return new Trade(fullAmount ? amount : money, ess);
} }
} }
catch (SignException e)
{
throw new SignException(Util.i18n("tradeSignEmpty"));
}
}
if (split.length == 3) if (split.length == 3)
{ {
@ -171,7 +186,7 @@ public class SignTrade extends EssentialsSign
amount -= amount % stackamount; amount -= amount % stackamount;
if (notEmpty && (amount < 1 || stackamount < 1 || item.getTypeId() == 0)) 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); item.setAmount(fullAmount ? amount : stackamount);
return new Trade(item, ess); return new Trade(item, ess);

View file

@ -291,7 +291,8 @@ timeSetPermission = \u00a7cYou are not authorized to set the time.
timeWorldCurrent = The current time in {0} is \u00a73{1} timeWorldCurrent = The current time in {0} is \u00a73{1}
timeWorldSet = The time was set to {0} in: \u00a7c{1} timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Trade completed. 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. treeFailure = \u00a7cTree generation failure. Try again on grass or dirt.
treeSpawned = \u00a77Tree spawned. treeSpawned = \u00a77Tree spawned.
typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77. 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} timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Forhandling fuldf\u00f8rt. tradeCompleted = \u00a77Forhandling fuldf\u00f8rt.
tradeSignEmpty = Forhandlings skiltet har ikke nok forsyning tilbage. 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. treeFailure = \u00a7cTr\u00e6 genererings fejl. Pr\u00f8v igen p\u00e5 gr\u00e6s eller jord.
treeSpawned = \u00a77Tr\u00e6 fremkaldt. treeSpawned = \u00a77Tr\u00e6 fremkaldt.
typeTpaccept = \u00a77For at teleportere, skriv \u00a7c/tpaccept\u00a77. 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} timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Handel abgeschlossen. tradeCompleted = \u00a77Handel abgeschlossen.
tradeSignEmpty = Der Bestand des Trade-Schild ist aufgebraucht. 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. treeFailure = \u00a7cBaumpflanzung gescheitert. Versuche es auf Gras oder Dreck.
treeSpawned = \u00a77Baum gepflanzt. treeSpawned = \u00a77Baum gepflanzt.
typeTpaccept = \u00a77Um zu teleportieren, schreibe \u00a7c/tpaccept\u00a77. 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} timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Trade completed. tradeCompleted = \u00a77Trade completed.
tradeSignEmpty = The trade sign does not have enough supply left. 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. treeFailure = \u00a7cTree generation failure. Try again on grass or dirt.
treeSpawned = \u00a77Tree spawned. treeSpawned = \u00a77Tree spawned.
typeTpaccept = \u00a77To teleport, type \u00a7c/tpaccept\u00a77. 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} timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77\u00c9change termin\u00e9. tradeCompleted = \u00a77\u00c9change termin\u00e9.
tradeSignEmpty = Le panneau de vente n''as pas encore assez de stock. 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. 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. treeSpawned = \u00a77Arbre cr\u00e9\u00e9.
typeTpaccept = \u00a77Pour le t\u00e9l\u00e9porter, tapez \u00a7c/tpaccept\u00a77. 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} timeWorldSet = The time was set to {0} in: \u00a7c{1}
tradeCompleted = \u00a77Ruil verricht. tradeCompleted = \u00a77Ruil verricht.
tradeSignEmpty = Het handelsbordje heeft een te kleine voorraad. 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. treeFailure = \u00a7cFout bij het genereren van boom. Pobeer het opnieuw op gras of dirt.
treeSpawned = \u00a77Boom gespawned. treeSpawned = \u00a77Boom gespawned.
typeTpaccept = \u00a77Om te teleporten, type \u00a7c/tpaccept\u00a77. typeTpaccept = \u00a77Om te teleporten, type \u00a7c/tpaccept\u00a77.