Add chest space to shop info message

Space only shown if selling enabled, stock only shown if buying enabled
This commit is contained in:
Eric 2019-06-03 17:03:24 +02:00
parent e6393ecd6c
commit c9ce45dc0c
7 changed files with 19 additions and 2 deletions

View File

@ -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")));

View File

@ -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,

View File

@ -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(" ");

View File

@ -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

View File

@ -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

View File

@ -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%

View File

@ -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%