From 20228dd6451cd620a51e9657a2cc2472345a8267 Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Fri, 18 Jan 2019 22:27:40 +0100 Subject: [PATCH] Fix amount in price restriction not working correctly Also fix copy and paste error in SELL_PRICE_BELOW_MIN error message. --- .../com/Acrobot/ChestShop/Configuration/Messages.java | 2 +- .../Listeners/Modules/PriceRestrictionModule.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java index 98d1d34..0753a67 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java @@ -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!"; diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/PriceRestrictionModule.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/PriceRestrictionModule.java index 4f99d71..b94d5e7 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/PriceRestrictionModule.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/PriceRestrictionModule.java @@ -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));