Fix trade sign length validation issues (#4748)

This commit is contained in:
Josh Roy 2022-02-13 15:50:43 -05:00 committed by GitHub
parent f00c2dcf92
commit a9e5f079a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,8 +116,8 @@ public class SignTrade extends EssentialsSign {
return true; return true;
} }
final Map<Integer, ItemStack> withdraw1 = stored1.pay(player, OverflowType.RETURN); final Map<Integer, ItemStack> withdraw1 = stored1.pay(player, OverflowType.DROP);
final Map<Integer, ItemStack> withdraw2 = stored2.pay(player, OverflowType.RETURN); final Map<Integer, ItemStack> withdraw2 = stored2.pay(player, OverflowType.DROP);
if (withdraw1 == null && withdraw2 == null) { if (withdraw1 == null && withdraw2 == null) {
Trade.log("Sign", "Trade", "Break", signOwner.substring(2), stored2, username, stored1, sign.getBlock().getLocation(), player.getMoney(), ess); Trade.log("Sign", "Trade", "Break", signOwner.substring(2), stored2, username, stored1, sign.getBlock().getLocation(), player.getMoney(), ess);
@ -206,7 +206,9 @@ public class SignTrade extends EssentialsSign {
if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) && getItemStack(split[1], stackamount, ess).getType() == Material.AIR) { if (!(split[1].equalsIgnoreCase("exp") || split[1].equalsIgnoreCase("xp")) && getItemStack(split[1], stackamount, ess).getType() == Material.AIR) {
throw new SignException(tl("moreThanZero")); throw new SignException(tl("moreThanZero"));
} }
sign.setLine(index, stackamount + " " + split[1] + ":" + amount); final String newline = stackamount + " " + split[1] + ":" + amount;
validateSignLength(newline);
sign.setLine(index, newline);
return; return;
} }
throw new SignException(tl("invalidSignLine", index + 1)); throw new SignException(tl("invalidSignLine", index + 1));