From c9ce45dc0cfa3acae359e1f45556d942f8e28ba9 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 3 Jun 2019 17:03:24 +0200 Subject: [PATCH] Add chest space to shop info message Space only shown if selling enabled, stock only shown if buying enabled --- .../de/epiceric/shopchest/language/LanguageUtils.java | 1 + .../java/de/epiceric/shopchest/language/Message.java | 1 + .../shopchest/listeners/ShopInteractListener.java | 9 +++++++-- src/main/resources/lang/de_DE-legacy.lang | 1 + src/main/resources/lang/de_DE.lang | 1 + src/main/resources/lang/en_US-legacy.lang | 4 ++++ src/main/resources/lang/en_US.lang | 4 ++++ 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java b/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java index cf1973c..3d777e5 100644 --- a/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java +++ b/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java @@ -2184,6 +2184,7 @@ public class LanguageUtils { messages.add(new LocalizedMessage(Message.SHOP_INFO_VENDOR, langConfig.getString("message.shopInfo.vendor", "&6Vendor: &e%VENDOR%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_PRODUCT, langConfig.getString("message.shopInfo.product", "&6Product: &e%AMOUNT% x %ITEMNAME%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_STOCK, langConfig.getString("message.shopInfo.stock", "&6In Stock: &e%STOCK%"))); + messages.add(new LocalizedMessage(Message.SHOP_INFO_CHEST_SPACE, langConfig.getString("message.shopInfo.chest-space", "&6Space in chest: &e%CHEST-SPACE%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_PRICE, langConfig.getString("message.shopInfo.price", "&6Price: Buy: &e%BUY-PRICE%&6 Sell: &e%SELL-PRICE%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_DISABLED, langConfig.getString("message.shopInfo.disabled", "&7Disabled"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_NORMAL, langConfig.getString("message.shopInfo.is-normal", "&6Type: &eNormal"))); diff --git a/src/main/java/de/epiceric/shopchest/language/Message.java b/src/main/java/de/epiceric/shopchest/language/Message.java index dfbffb9..db168a5 100644 --- a/src/main/java/de/epiceric/shopchest/language/Message.java +++ b/src/main/java/de/epiceric/shopchest/language/Message.java @@ -14,6 +14,7 @@ public enum Message { SHOP_INFO_VENDOR, SHOP_INFO_PRODUCT, SHOP_INFO_STOCK, + SHOP_INFO_CHEST_SPACE, SHOP_INFO_PRICE, SHOP_INFO_DISABLED, SHOP_INFO_NORMAL, diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java index 22a3499..5fa40cb 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java @@ -592,6 +592,7 @@ public class ShopInteractListener implements Listener { Chest c = (Chest) shop.getLocation().getBlock().getState(); ItemStack itemStack = shop.getProduct().getItemStack(); int amount = Utils.getAmount(c.getInventory(), itemStack); + int space = Utils.getFreeSpaceForItem(c.getInventory(), itemStack); String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName()); @@ -612,12 +613,16 @@ public class ShopInteractListener implements Listener { Message.SHOP_INFO_NORMAL : Message.SHOP_INFO_ADMIN); String stock = LanguageUtils.getMessage(Message.SHOP_INFO_STOCK, - new Replacement(Placeholder.STOCK, String.valueOf(amount))); + new Replacement(Placeholder.STOCK, amount)); + + String chestSpace = LanguageUtils.getMessage(Message.SHOP_INFO_CHEST_SPACE, + new Replacement(Placeholder.CHEST_SPACE, space)); executor.sendMessage(" "); if (shop.getShopType() != ShopType.ADMIN) executor.sendMessage(vendorString); jb.sendJson(executor); - if (shop.getShopType() != ShopType.ADMIN) executor.sendMessage(stock); + if (shop.getShopType() != ShopType.ADMIN && shop.getBuyPrice() > 0) executor.sendMessage(stock); + if (shop.getShopType() != ShopType.ADMIN && shop.getSellPrice() > 0) executor.sendMessage(chestSpace); executor.sendMessage(priceString); executor.sendMessage(shopType); executor.sendMessage(" "); diff --git a/src/main/resources/lang/de_DE-legacy.lang b/src/main/resources/lang/de_DE-legacy.lang index 05714a6..34da71a 100644 --- a/src/main/resources/lang/de_DE-legacy.lang +++ b/src/main/resources/lang/de_DE-legacy.lang @@ -11,6 +11,7 @@ message.shop-create-not-enough-money=&cNicht genug Geld. Du brauchst &6%CREATION message.shopInfo.vendor=&6Verkäufer: &e%VENDOR% message.shopInfo.product=&6Produkt: &e%AMOUNT% x %ITEMNAME% message.shopInfo.stock=&6Auf Lager: &e%STOCK% +message.shopInfo.chest-space=&6Platz in Truhe: &e%CHEST-SPACE% message.shopInfo.price=&6Preis: Kauf: &e%BUY-PRICE%&6 Verkauf: &e%SELL-PRICE% message.shopInfo.disabled=&7Deaktiviert message.shopInfo.is-normal=&6Typ: &eNormal diff --git a/src/main/resources/lang/de_DE.lang b/src/main/resources/lang/de_DE.lang index 91ed4ca..c06b1cb 100644 --- a/src/main/resources/lang/de_DE.lang +++ b/src/main/resources/lang/de_DE.lang @@ -11,6 +11,7 @@ message.shop-create-not-enough-money=&cNicht genug Geld. Du brauchst &6%CREATION message.shopInfo.vendor=&6Verkäufer: &e%VENDOR% message.shopInfo.product=&6Produkt: &e%AMOUNT% x %ITEMNAME% message.shopInfo.stock=&6Auf Lager: &e%STOCK% +message.shopInfo.chest-space=&6Platz in Truhe: &e%CHEST-SPACE% message.shopInfo.price=&6Preis: Kauf: &e%BUY-PRICE%&6 Verkauf: &e%SELL-PRICE% message.shopInfo.disabled=&7Deaktiviert message.shopInfo.is-normal=&6Typ: &eNormal diff --git a/src/main/resources/lang/en_US-legacy.lang b/src/main/resources/lang/en_US-legacy.lang index 8efceed..00bd652 100644 --- a/src/main/resources/lang/en_US-legacy.lang +++ b/src/main/resources/lang/en_US-legacy.lang @@ -54,6 +54,10 @@ message.shopInfo.product=&6Product: &e%AMOUNT% x %ITEMNAME% # Usable Placeholders=%STOCK% message.shopInfo.stock=&6In Stock: &e%STOCK% +# Set the chest-space message the player after entering '/shop info'. +# Usable Placeholders=%CHEST-SPACE% +message.shopInfo.chest-space=&6Space in chest: &e%CHEST-SPACE% + # Set the price message the player gets after entering '/shop info'. # Usable Placeholders: %BUY-PRICE%, %SELL-PRICE% message.shopInfo.price=&6Price: Buy: &e%BUY-PRICE%&6 Sell: &e%SELL-PRICE% diff --git a/src/main/resources/lang/en_US.lang b/src/main/resources/lang/en_US.lang index 41c42e2..f1b0c5f 100644 --- a/src/main/resources/lang/en_US.lang +++ b/src/main/resources/lang/en_US.lang @@ -47,6 +47,10 @@ message.shopInfo.product=&6Product: &e%AMOUNT% x %ITEMNAME% # Usable Placeholders=%STOCK% message.shopInfo.stock=&6In Stock: &e%STOCK% +# Set the chest-space message the player after entering '/shop info'. +# Usable Placeholders=%CHEST-SPACE% +message.shopInfo.chest-space=&6Space in chest: &e%CHEST-SPACE% + # Set the price message the player gets after entering '/shop info'. # Usable Placeholders: %BUY-PRICE%, %SELL-PRICE% message.shopInfo.price=&6Price: Buy: &e%BUY-PRICE%&6 Sell: &e%SELL-PRICE%