Fix stack trace when buying from sign when inventory full

PR #5736 made ChargeException implement TranslatableException and in
doing so, changed the meaning of its constructor. However there were 2
uses of that constructor that did not pass a locale key as is expected
now, and instead passed in a regular string. These 2 uses are when you
attempt to use a buy sign or a trade sign, and the operation fails
because your inventory is full.

This causes the translator to blow up and put an error trace in the
console, as EssentialsX's translator has no fallbacks.
There were no other perceivable issues other than the console spam.

This PR also resolves a TODO.
This commit is contained in:
Emilia Kond 2024-04-14 00:33:30 +03:00
parent c85e179718
commit d4107c85ac
No known key found for this signature in database
GPG Key ID: 7F86133879F6DD61
3 changed files with 3 additions and 2 deletions

View File

@ -46,7 +46,7 @@ public class SignBuy extends EssentialsSign {
charge.isAffordableFor(player);
if (!items.pay(player)) {
throw new ChargeException("Inventory full"); //TODO: TL
throw new ChargeException("inventoryFull");
}
charge.charge(player);
Trade.log("Sign", "Buy", "Interact", username, charge, username, items, sign.getBlock().getLocation(), player.getMoney(), ess);

View File

@ -72,7 +72,7 @@ public class SignTrade extends EssentialsSign {
if (!trade.pay(player)) {
subtractAmount(sign, 1, charge, ess);
addAmount(sign, 2, trade, ess);
throw new ChargeException("Full inventory");
throw new ChargeException("inventoryFull");
}
charge.charge(player);
Trade.log("Sign", "Trade", "Interact", sign.getLine(3).substring(2), charge, username, trade, sign.getBlock().getLocation(), player.getMoney(), ess);

View File

@ -561,6 +561,7 @@ inventoryClearingAllArmor=<primary>Cleared all inventory items and armor from<se
inventoryClearingAllItems=<primary>Cleared all inventory items from<secondary> {0}<primary>.
inventoryClearingFromAll=<primary>Clearing the inventory of all users...
inventoryClearingStack=<primary>Removed<secondary> {0} <primary>of<secondary> {1} <primary>from<secondary> {2}<primary>.
inventoryFull=<dark_red>Your inventory is full.
invseeCommandDescription=See the inventory of other players.
invseeCommandUsage=/<command> <player>
invseeCommandUsage1=/<command> <player>