mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-06 02:30:07 +01:00
Add different error messages when price limits are exceeded (#193)
This commit is contained in:
parent
6fe6f80538
commit
c8d0590614
@ -50,6 +50,12 @@ public class Messages {
|
||||
public static String INVALID_SHOP_DETECTED = "The shop cannot be used!";
|
||||
public static String CANNOT_ACCESS_THE_CHEST = "You don't have permissions to access this chest!";
|
||||
|
||||
@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 BUY_PRICE_ABOVE_MAX = "Buy price is above maximum!";
|
||||
public static String BUY_PRICE_BELOW_MIN ="Buy price is below minimum!";
|
||||
|
||||
@PrecededBySpace
|
||||
public static String CLICK_TO_AUTOFILL_ITEM = "Click the sign with the item that this shop is for!";
|
||||
public static String NO_ITEM_IN_HAND = "You don't have an item in your hand to autofill!";
|
||||
|
@ -159,6 +159,10 @@ public class PreShopCreationEvent extends Event implements Cancellable {
|
||||
UNKNOWN_PLAYER,
|
||||
|
||||
SELL_PRICE_HIGHER_THAN_BUY_PRICE,
|
||||
SELL_PRICE_ABOVE_MAX,
|
||||
SELL_PRICE_BELOW_MIN,
|
||||
BUY_PRICE_ABOVE_MAX,
|
||||
BUY_PRICE_BELOW_MIN,
|
||||
|
||||
NO_CHEST,
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.Acrobot.ChestShop.Listeners.Modules;
|
||||
|
||||
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
||||
import com.Acrobot.Breeze.Utils.NumberUtil;
|
||||
import com.Acrobot.Breeze.Utils.PriceUtil;
|
||||
import com.Acrobot.ChestShop.ChestShop;
|
||||
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -17,7 +15,10 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.INVALID_PRICE;
|
||||
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.BUY_PRICE_ABOVE_MAX;
|
||||
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.BUY_PRICE_BELOW_MIN;
|
||||
import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.SELL_PRICE_ABOVE_MAX;
|
||||
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;
|
||||
|
||||
@ -102,11 +103,11 @@ public class PriceRestrictionModule implements Listener {
|
||||
double buyPrice = PriceUtil.getBuyPrice(event.getSignLine(PRICE_LINE));
|
||||
|
||||
if (isValid("min.buy_price." + itemType) && buyPrice < (configuration.getDouble("min.buy_price." + itemType) / amount)) {
|
||||
event.setOutcome(INVALID_PRICE);
|
||||
event.setOutcome(BUY_PRICE_BELOW_MIN);
|
||||
}
|
||||
|
||||
if (isValid("max.buy_price." + itemType) && buyPrice > (configuration.getDouble("max.buy_price." + itemType) / amount)) {
|
||||
event.setOutcome(INVALID_PRICE);
|
||||
event.setOutcome(BUY_PRICE_ABOVE_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,11 +115,11 @@ public class PriceRestrictionModule implements Listener {
|
||||
double sellPrice = PriceUtil.getSellPrice(event.getSignLine(PRICE_LINE));
|
||||
|
||||
if (isValid("min.sell_price." + itemType) && sellPrice < (configuration.getDouble("min.sell_price." + itemType) / amount)) {
|
||||
event.setOutcome(INVALID_PRICE);
|
||||
event.setOutcome(SELL_PRICE_BELOW_MIN);
|
||||
}
|
||||
|
||||
if (isValid("max.sell_price." + itemType) && sellPrice > (configuration.getDouble("max.sell_price." + itemType) / amount)) {
|
||||
event.setOutcome(INVALID_PRICE);
|
||||
event.setOutcome(SELL_PRICE_ABOVE_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,18 @@ public class ErrorMessageSender implements Listener {
|
||||
case SELL_PRICE_HIGHER_THAN_BUY_PRICE:
|
||||
message = Messages.YOU_CANNOT_CREATE_SHOP;
|
||||
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:
|
||||
message = Messages.NO_CHEST_DETECTED;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user