From c9a63c7cbb688bcdb899383bc4e331d79f2363d9 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 6 Sep 2016 11:43:01 +0200 Subject: [PATCH] Display "Disabled" instead of 0$ when selling/buying is disabled --- .../java/de/epiceric/shopchest/language/LanguageUtils.java | 6 ++++-- .../epiceric/shopchest/listeners/ShopInteractListener.java | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java b/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java index b7f4c9c..f95341a 100644 --- a/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java +++ b/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java @@ -1109,8 +1109,10 @@ public class LanguageUtils { Regex regex = replacedRegex.getRegex(); String toReplace = replacedRegex.getReplace(); if (regex == Regex.BUY_PRICE || regex == Regex.SELL_PRICE || regex == Regex.MIN_PRICE || regex == Regex.CREATION_PRICE) { - double price = Double.parseDouble(toReplace); - toReplace = plugin.getEconomy().format(price); + if (!toReplace.equals(getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED))) { + double price = Double.parseDouble(toReplace); + toReplace = plugin.getEconomy().format(price); + } } _message = _message.replace(regex.getName(), toReplace); usedRegexes.add(regex); diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java index e8de0b9..828400f 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java @@ -346,8 +346,9 @@ public class ShopInteractListener implements Listener { String enchantmentString = ""; String potionEffectString = ""; String musicDiscName = LanguageUtils.getMusicDiscName(type); - String price = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRICE, new LocalizedMessage.ReplacedRegex(Regex.BUY_PRICE, String.valueOf(shop.getBuyPrice())), - new LocalizedMessage.ReplacedRegex(Regex.SELL_PRICE, String.valueOf(shop.getSellPrice()))); + String disabled = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED); + 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 stock = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(amount)));