From 4194c72bd4cb97fc47bef4c88adce857d5818799 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 4 Jan 2017 18:46:50 +0100 Subject: [PATCH] Added vendor information about a sold out shop --- .../java/de/epiceric/shopchest/language/LanguageUtils.java | 1 + .../de/epiceric/shopchest/language/LocalizedMessage.java | 1 + .../epiceric/shopchest/listeners/ShopInteractListener.java | 5 +++++ src/main/resources/config.yml | 2 +- src/main/resources/lang/de_DE.lang | 1 + src/main/resources/lang/en_US.lang | 3 +++ 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java b/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java index fd4a153..18bcb49 100644 --- a/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java +++ b/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java @@ -939,6 +939,7 @@ public class LanguageUtils { messages.add(new LocalizedMessage(LocalizedMessage.Message.NOT_ENOUGH_ITEMS, langConfig.getString("message.not-enough-items", "&cNot enough items."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.VENDOR_NOT_ENOUGH_MONEY, langConfig.getString("message.vendor-not-enough-money", "&cVendor has not enough money."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.OUT_OF_STOCK, langConfig.getString("message.out-of-stock", "&cShop out of stock."))); + messages.add(new LocalizedMessage(LocalizedMessage.Message.VENDOR_OUT_OF_STOCK, langConfig.getString("message.vendor-out-of-stock", "&cYour shop that sells &6%AMOUNT% x %ITEMNAME% &cis out of stock."), Regex.AMOUNT, Regex.ITEM_NAME)); messages.add(new LocalizedMessage(LocalizedMessage.Message.ERROR_OCCURRED, langConfig.getString("message.error-occurred", "&cAn error occurred: %ERROR%"), Regex.ERROR)); messages.add(new LocalizedMessage(LocalizedMessage.Message.AMOUNT_PRICE_NOT_NUMBER, langConfig.getString("message.amount-and-price-not-number", "&cAmount and price must be a number."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.AMOUNT_IS_ZERO, langConfig.getString("message.amount-is-zero", "&cAmount must be greater than 0."))); diff --git a/src/main/java/de/epiceric/shopchest/language/LocalizedMessage.java b/src/main/java/de/epiceric/shopchest/language/LocalizedMessage.java index 64e42f8..aed652b 100644 --- a/src/main/java/de/epiceric/shopchest/language/LocalizedMessage.java +++ b/src/main/java/de/epiceric/shopchest/language/LocalizedMessage.java @@ -74,6 +74,7 @@ public class LocalizedMessage { NOT_ENOUGH_ITEMS, VENDOR_NOT_ENOUGH_MONEY, OUT_OF_STOCK, + VENDOR_OUT_OF_STOCK, ERROR_OCCURRED, AMOUNT_PRICE_NOT_NUMBER, AMOUNT_IS_ZERO, diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java index 06585bd..f93fed6 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java @@ -284,6 +284,11 @@ public class ShopInteractListener implements Listener { buy(p, shop); } else { p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OUT_OF_STOCK)); + if (shop.getVendor().isOnline() && config.enable_vendor_messages) { + shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.VENDOR_OUT_OF_STOCK, + new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(shop.getProduct().getAmount())), + new LocalizedMessage.ReplacedRegex(Regex.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct())))); + } plugin.debug("Shop is out of stock"); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e1a9811..e2dcdf5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,7 +40,7 @@ enable-worldguard-integration: true enable-towny-integration: true # Set whether the vendor of a shop should get messages when players -# buy or sell something from/to his shop +# buy or sell something from/to his shop or if his shop is out of stock enable-vendor-messages: true # Set whether the buy- and sell price should be arranged below each other. diff --git a/src/main/resources/lang/de_DE.lang b/src/main/resources/lang/de_DE.lang index 7f312a6..ec71b8b 100644 --- a/src/main/resources/lang/de_DE.lang +++ b/src/main/resources/lang/de_DE.lang @@ -30,6 +30,7 @@ message.not-enough-money=&cNicht genug Geld. message.not-enough-items=&cNicht genug Items. message.vendor-not-enough-money=&cVerkäufer hat nicht genug Geld. message.out-of-stock=&cShop ausverkauft. +message.vendor-out-of-stock=&cDein Shop, der &6%AMOUNT% x %ITEMNAME% &cverkauft, ist ausverkauft. message.error-occurred=&cEin Fehler ist aufgetreten: %ERROR% message.amount-and-price-not-number=&cAnzahl und Preise müssen Zahlen sein. message.amount-is-zero=&cAnzahl muss größer als 0 sein. diff --git a/src/main/resources/lang/en_US.lang b/src/main/resources/lang/en_US.lang index 3c328f4..314c741 100644 --- a/src/main/resources/lang/en_US.lang +++ b/src/main/resources/lang/en_US.lang @@ -111,6 +111,9 @@ message.vendor-not-enough-money=&cVendor has not enough money. # Set the message when the shop is out of stock. message.out-of-stock=&cShop out of stock. +# Set the message the vendor gets when his shop is out of stock +message.vendor-out-of-stock=&cYour shop that sells &6%AMOUNT% x %ITEMNAME% &cis out of stock. + # Set the message when an error occurred. # Usable regex: %ERROR% message.error-occurred=&cAn error occurred: %ERROR%