Display "Disabled" instead of 0$ when selling/buying is disabled

This commit is contained in:
Eric 2016-09-06 11:43:01 +02:00
parent da772fcbd6
commit c9a63c7cbb
2 changed files with 7 additions and 4 deletions

View File

@ -1109,8 +1109,10 @@ public class LanguageUtils {
Regex regex = replacedRegex.getRegex(); Regex regex = replacedRegex.getRegex();
String toReplace = replacedRegex.getReplace(); String toReplace = replacedRegex.getReplace();
if (regex == Regex.BUY_PRICE || regex == Regex.SELL_PRICE || regex == Regex.MIN_PRICE || regex == Regex.CREATION_PRICE) { if (regex == Regex.BUY_PRICE || regex == Regex.SELL_PRICE || regex == Regex.MIN_PRICE || regex == Regex.CREATION_PRICE) {
double price = Double.parseDouble(toReplace); if (!toReplace.equals(getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED))) {
toReplace = plugin.getEconomy().format(price); double price = Double.parseDouble(toReplace);
toReplace = plugin.getEconomy().format(price);
}
} }
_message = _message.replace(regex.getName(), toReplace); _message = _message.replace(regex.getName(), toReplace);
usedRegexes.add(regex); usedRegexes.add(regex);

View File

@ -346,8 +346,9 @@ public class ShopInteractListener implements Listener {
String enchantmentString = ""; String enchantmentString = "";
String potionEffectString = ""; String potionEffectString = "";
String musicDiscName = LanguageUtils.getMusicDiscName(type); String musicDiscName = LanguageUtils.getMusicDiscName(type);
String price = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRICE, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, String.valueOf(shop.getBuyPrice())), String disabled = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED);
new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, String.valueOf(shop.getSellPrice()))); String price = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRICE, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, (shop.getBuyPrice() > 0 ? String.valueOf(shop.getBuyPrice()) : disabled)),
new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, (shop.getSellPrice() > 0 ? String.valueOf(shop.getSellPrice()) : disabled)));
String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ? LocalizedMessage.Message.SHOP_INFO_NORMAL : LocalizedMessage.Message.SHOP_INFO_ADMIN); String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ? LocalizedMessage.Message.SHOP_INFO_NORMAL : LocalizedMessage.Message.SHOP_INFO_ADMIN);
String stock = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(amount))); String stock = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(amount)));