Fix amount in price restriction not working correctly

Also fix copy and paste error in SELL_PRICE_BELOW_MIN error message.
This commit is contained in:
Phoenix616 2019-01-18 22:27:40 +01:00
parent 91a372bd05
commit 20228dd645
2 changed files with 8 additions and 2 deletions

View File

@ -52,7 +52,7 @@ public class Messages {
@PrecededBySpace
public static String SELL_PRICE_ABOVE_MAX = "Sell price is above maximum!";
public static String SELL_PRICE_BELOW_MIN ="Buy price is below minimum!";
public static String SELL_PRICE_BELOW_MIN ="Sell price is below minimum!";
public static String BUY_PRICE_ABOVE_MAX = "Buy price is above maximum!";
public static String BUY_PRICE_BELOW_MIN ="Buy price is below minimum!";

View File

@ -22,6 +22,7 @@ import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.SELL_PRICE_BELOW_MIN;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.ITEM_LINE;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.PRICE_LINE;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.QUANTITY_LINE;
/**
* @author Acrobot
@ -100,7 +101,12 @@ public class PriceRestrictionModule implements Listener {
}
String itemType = material.getType().toString().toLowerCase();
int amount = material.getAmount();
int amount;
try {
amount = Integer.parseInt(event.getSignLine(QUANTITY_LINE));
} catch (IllegalArgumentException e) {
return;
}
if (PriceUtil.hasBuyPrice(event.getSignLine(PRICE_LINE))) {
double buyPrice = PriceUtil.getBuyPrice(event.getSignLine(PRICE_LINE));