mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-25 19:45:36 +01:00
Include prices in price restriction messages (Resolves #461)
This commit is contained in:
parent
1b85bda656
commit
965d931978
@ -3,6 +3,7 @@ package com.Acrobot.ChestShop.Listeners.Modules;
|
|||||||
import com.Acrobot.Breeze.Utils.PriceUtil;
|
import com.Acrobot.Breeze.Utils.PriceUtil;
|
||||||
import com.Acrobot.Breeze.Utils.QuantityUtil;
|
import com.Acrobot.Breeze.Utils.QuantityUtil;
|
||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||||
import com.Acrobot.ChestShop.Events.ChestShopReloadEvent;
|
import com.Acrobot.ChestShop.Events.ChestShopReloadEvent;
|
||||||
import com.Acrobot.ChestShop.Events.ItemParseEvent;
|
import com.Acrobot.ChestShop.Events.ItemParseEvent;
|
||||||
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
||||||
@ -124,24 +125,32 @@ public class PriceRestrictionModule implements Listener {
|
|||||||
if (PriceUtil.hasBuyPrice(event.getSignLine(PRICE_LINE))) {
|
if (PriceUtil.hasBuyPrice(event.getSignLine(PRICE_LINE))) {
|
||||||
BigDecimal buyPrice = PriceUtil.getExactBuyPrice(event.getSignLine(PRICE_LINE));
|
BigDecimal buyPrice = PriceUtil.getExactBuyPrice(event.getSignLine(PRICE_LINE));
|
||||||
|
|
||||||
if (isValid("min.buy_price." + itemType) && buyPrice.compareTo(BigDecimal.valueOf(configuration.getDouble("min.buy_price." + itemType) * amount)) < 0) {
|
BigDecimal minBuyPrice = BigDecimal.valueOf(configuration.getDouble("min.buy_price." + itemType) * amount);
|
||||||
|
if (isValid("min.buy_price." + itemType) && buyPrice.compareTo(minBuyPrice) < 0) {
|
||||||
event.setOutcome(BUY_PRICE_BELOW_MIN);
|
event.setOutcome(BUY_PRICE_BELOW_MIN);
|
||||||
|
Messages.BUY_PRICE_ABOVE_MAX.sendWithPrefix(event.getPlayer(), "price", buyPrice.toPlainString(), "minprice", minBuyPrice.toPlainString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isValid("max.buy_price." + itemType) && buyPrice.compareTo(BigDecimal.valueOf(configuration.getDouble("max.buy_price." + itemType) * amount)) > 0) {
|
BigDecimal maxBuyPrice = BigDecimal.valueOf(configuration.getDouble("max.buy_price." + itemType) * amount);
|
||||||
|
if (isValid("max.buy_price." + itemType) && buyPrice.compareTo(maxBuyPrice) > 0) {
|
||||||
event.setOutcome(BUY_PRICE_ABOVE_MAX);
|
event.setOutcome(BUY_PRICE_ABOVE_MAX);
|
||||||
|
Messages.BUY_PRICE_ABOVE_MAX.sendWithPrefix(event.getPlayer(), "price", buyPrice.toPlainString(), "maxprice", maxBuyPrice.toPlainString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PriceUtil.hasSellPrice(event.getSignLine(PRICE_LINE))) {
|
if (PriceUtil.hasSellPrice(event.getSignLine(PRICE_LINE))) {
|
||||||
BigDecimal sellPrice = PriceUtil.getExactSellPrice(event.getSignLine(PRICE_LINE));
|
BigDecimal sellPrice = PriceUtil.getExactSellPrice(event.getSignLine(PRICE_LINE));
|
||||||
|
|
||||||
if (isValid("min.sell_price." + itemType) && sellPrice.compareTo(BigDecimal.valueOf(configuration.getDouble("min.sell_price." + itemType) * amount)) < 0) {
|
BigDecimal minSellPrice = BigDecimal.valueOf(configuration.getDouble("min.sell_price." + itemType) * amount);
|
||||||
|
if (isValid("min.sell_price." + itemType) && sellPrice.compareTo(minSellPrice) < 0) {
|
||||||
event.setOutcome(SELL_PRICE_BELOW_MIN);
|
event.setOutcome(SELL_PRICE_BELOW_MIN);
|
||||||
|
Messages.BUY_PRICE_ABOVE_MAX.sendWithPrefix(event.getPlayer(), "price", sellPrice.toPlainString(), "minprice", minSellPrice.toPlainString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isValid("max.sell_price." + itemType) && sellPrice.compareTo(BigDecimal.valueOf(configuration.getDouble("max.sell_price." + itemType) * amount)) > 0) {
|
BigDecimal maxSellPrice = BigDecimal.valueOf(configuration.getDouble("max.sell_price." + itemType) * amount);
|
||||||
|
if (isValid("max.sell_price." + itemType) && sellPrice.compareTo(maxSellPrice) > 0) {
|
||||||
event.setOutcome(SELL_PRICE_ABOVE_MAX);
|
event.setOutcome(SELL_PRICE_ABOVE_MAX);
|
||||||
|
Messages.BUY_PRICE_ABOVE_MAX.sendWithPrefix(event.getPlayer(), "price", sellPrice.toPlainString(), "maxprice", maxSellPrice.toPlainString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,18 +35,6 @@ public class ErrorMessageSender implements Listener {
|
|||||||
case SELL_PRICE_HIGHER_THAN_BUY_PRICE:
|
case SELL_PRICE_HIGHER_THAN_BUY_PRICE:
|
||||||
message = Messages.YOU_CANNOT_CREATE_SHOP;
|
message = Messages.YOU_CANNOT_CREATE_SHOP;
|
||||||
break;
|
break;
|
||||||
case SELL_PRICE_ABOVE_MAX:
|
|
||||||
message = Messages.SELL_PRICE_ABOVE_MAX;
|
|
||||||
break;
|
|
||||||
case SELL_PRICE_BELOW_MIN:
|
|
||||||
message = Messages.SELL_PRICE_BELOW_MIN;
|
|
||||||
break;
|
|
||||||
case BUY_PRICE_ABOVE_MAX:
|
|
||||||
message = Messages.BUY_PRICE_ABOVE_MAX;
|
|
||||||
break;
|
|
||||||
case BUY_PRICE_BELOW_MIN:
|
|
||||||
message = Messages.BUY_PRICE_BELOW_MIN;
|
|
||||||
break;
|
|
||||||
case NO_CHEST:
|
case NO_CHEST:
|
||||||
message = Messages.NO_CHEST_DETECTED;
|
message = Messages.NO_CHEST_DETECTED;
|
||||||
break;
|
break;
|
||||||
|
@ -64,10 +64,10 @@ INVALID_SHOP_PRICE: "The shop has an invalid price!"
|
|||||||
INVALID_SHOP_QUANTITY: "The shop has an invalid quantity!"
|
INVALID_SHOP_QUANTITY: "The shop has an invalid quantity!"
|
||||||
CANNOT_ACCESS_THE_CHEST: "You don't have permissions to access this chest!"
|
CANNOT_ACCESS_THE_CHEST: "You don't have permissions to access this chest!"
|
||||||
|
|
||||||
SELL_PRICE_ABOVE_MAX: "Sell price is above maximum!"
|
SELL_PRICE_ABOVE_MAX: "Sell price %price is above maximum %maxprice!"
|
||||||
SELL_PRICE_BELOW_MIN: "Sell price is below minimum!"
|
SELL_PRICE_BELOW_MIN: "Sell price %price is below minimum %minprice!"
|
||||||
BUY_PRICE_ABOVE_MAX: "Buy price is above maximum!"
|
BUY_PRICE_ABOVE_MAX: "Buy price %price is above maximum %maxprice!"
|
||||||
BUY_PRICE_BELOW_MIN: "Buy price is below minimum!"
|
BUY_PRICE_BELOW_MIN: "Buy price %price is below minimum %minprice!"
|
||||||
|
|
||||||
CLICK_TO_AUTOFILL_ITEM: "Click the sign with the item that this shop is for!"
|
CLICK_TO_AUTOFILL_ITEM: "Click the sign with the item that this shop is for!"
|
||||||
NO_ITEM_IN_HAND: "You don't have an item in your hand to autofill!"
|
NO_ITEM_IN_HAND: "You don't have an item in your hand to autofill!"
|
||||||
|
Loading…
Reference in New Issue
Block a user