diff --git a/config.yml b/config.yml index 5668ef0..2da06d9 100644 --- a/config.yml +++ b/config.yml @@ -131,10 +131,18 @@ messages: # Usable regex: %AMOUNT%, %ITEMNAME%, %BUY-PRICE%, %CURRENCY-SYMBOL%, %VENDOR% buy-success: "&aYou bought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%%CURRENCY-SYMBOL%&a from &6%VENDOR%&a." - # Set the message when the player successfully bought something. + # Set the message when the player successfully sold something. # Usable regex: %AMOUNT%, %ITEMNAME%, %SELL-PRICE%, %CURRENCY-SYMBOL%, %VENDOR% sell-success: "&aYou sold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%%CURRENCY-SYMBOL%&a to &6%VENDOR%&a." + # Set the message when a player bought something from the players' shop. + # Usable regex: %AMOUNT%, %ITEMNAME%, %BUY-PRICE%, %CURRENCY-SYMBOL%, %PLAYER% + someone-bought: "&6%PLAYER% &abought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%%CURRENCY-SYMBOL%&a from your shop." + + # Set the message when a player sold something to the players' shop. + # Usable regex: %AMOUNT%, %ITEMNAME%, %SELL-PRICE%, %CURRENCY-SYMBOL%, %PLAYER% + someone-sold: "&6%PLAYER% &asold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%%CURRENCY-SYMBOL%&a from your shop." + # Set the message when the inventory is full when the player is buying something. not-enough-inventory-space: "&cNot enough space in inventory." diff --git a/src/de/epiceric/shopchest/config/Config.java b/src/de/epiceric/shopchest/config/Config.java index 9ae7b2b..1c2f5b2 100644 --- a/src/de/epiceric/shopchest/config/Config.java +++ b/src/de/epiceric/shopchest/config/Config.java @@ -134,6 +134,14 @@ public class Config { return plugin.getConfig().getString("messages.sell-success").replace(Regex.currencySymbol, currency_symbol()).replace(Regex.amount, String.valueOf(amount)).replace(Regex.itemName, itemName).replace(Regex.sellPrice, String.valueOf(sellPrice)).replace(Regex.vendor, vendor).replaceAll("(&([a-f0-9k-or]))", "\u00A7$2"); } + public static String someone_bought(int amount, String itemName, double sellPrice, String player) { + return plugin.getConfig().getString("messages.someone-bought").replace(Regex.currencySymbol, currency_symbol()).replace(Regex.amount, String.valueOf(amount)).replace(Regex.itemName, itemName).replace(Regex.sellPrice, String.valueOf(sellPrice)).replace(Regex.player, player).replaceAll("(&([a-f0-9k-or]))", "\u00A7$2"); + } + + public static String someone_sold(int amount, String itemName, double sellPrice, String player) { + return plugin.getConfig().getString("messages.someone-sold").replace(Regex.currencySymbol, currency_symbol()).replace(Regex.amount, String.valueOf(amount)).replace(Regex.itemName, itemName).replace(Regex.sellPrice, String.valueOf(sellPrice)).replace(Regex.player, player).replaceAll("(&([a-f0-9k-or]))", "\u00A7$2"); + } + public static String occupied_shop_slots(int limit, int amount) { return plugin.getConfig().getString("messages.occupied-shop-slots").replace(Regex.limit, String.valueOf(limit)).replace(Regex.amount, String.valueOf(amount)).replaceAll("(&([a-f0-9k-or]))", "\u00A7$2"); } diff --git a/src/de/epiceric/shopchest/config/Regex.java b/src/de/epiceric/shopchest/config/Regex.java index e1325c1..fa91133 100644 --- a/src/de/epiceric/shopchest/config/Regex.java +++ b/src/de/epiceric/shopchest/config/Regex.java @@ -14,5 +14,6 @@ public class Regex { public static String buyPrice = "%BUY-PRICE%"; public static String sellPrice = "%SELL-PRICE%"; public static String limit = "%LIMIT%"; + public static String player = "%PLAYER%"; } diff --git a/src/de/epiceric/shopchest/event/InteractShop.java b/src/de/epiceric/shopchest/event/InteractShop.java index 034a840..47ed7da 100644 --- a/src/de/epiceric/shopchest/event/InteractShop.java +++ b/src/de/epiceric/shopchest/event/InteractShop.java @@ -342,6 +342,7 @@ public class InteractShop implements Listener{ leftAmount--; } else if (leftAmount == 0) { executor.sendMessage(Config.buy_success(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), shop.getVendor().getName())); + if (shop.getVendor().isOnline()) shop.getVendor().getPlayer().sendMessage(Config.someone_bought(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), executor.getName())); return; } } @@ -416,6 +417,7 @@ public class InteractShop implements Listener{ leftAmount--; } else if (leftAmount == 0) { executor.sendMessage(Config.sell_success(product.getAmount(), ItemNames.lookup(product), shop.getSellPrice(), shop.getVendor().getName())); + if (shop.getVendor().isOnline()) shop.getVendor().getPlayer().sendMessage(Config.someone_sold(product.getAmount(), ItemNames.lookup(product), shop.getBuyPrice(), executor.getName())); return; } }