diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java index 743160f..bd10a02 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Messages.java @@ -7,8 +7,8 @@ import org.bukkit.ChatColor; * @author Acrobot */ public class Messages { - public static String prefix = ChatColor.GREEN + "[Shop] " + ChatColor.RESET; - public static String iteminfo = ChatColor.GREEN + "Item Information: " + ChatColor.RESET; + public static String prefix = "&a[Shop] &r"; + public static String iteminfo = "&aItem Information: &r"; @PrecededBySpace public static String ACCESS_DENIED = "You don't have permission to do that!"; @@ -29,10 +29,11 @@ public class Messages { public static String NOT_ENOUGH_SPACE_IN_INVENTORY = "You haven't got enough space in inventory!"; public static String NOT_ENOUGH_SPACE_IN_CHEST = "There isn't enough space in chest!"; public static String NOT_ENOUGH_ITEMS_TO_SELL = "You don't have enough items to sell!"; + public static String NOT_ENOUGH_SPACE_IN_YOUR_SHOP = "%material&7 shop at &r%world/%x/%y/%z&7 is full! (%seller tried to sell)"; @PrecededBySpace public static String NOT_ENOUGH_STOCK = "This shop is out of stock."; - public static String NOT_ENOUGH_STOCK_IN_YOUR_SHOP = "Your %material shop is out of stock!"; + public static String NOT_ENOUGH_STOCK_IN_YOUR_SHOP = "%material&7 shop at &r%world/%x/%y/%z&7 is out of stock! (%buyer tried to buy)"; @PrecededBySpace public static String YOU_BOUGHT_FROM_SHOP = "You bought %item from %owner for %price."; @@ -72,6 +73,6 @@ public class Messages { public static String TOGGLE_MESSAGES_ON = "You will now receive messages from your shop(s)."; public static String prefix(String message) { - return prefix + message; + return ChatColor.translateAlternateColorCodes('&', prefix + message); } } diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java index 3fad489..84545de 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java @@ -70,7 +70,7 @@ public class Properties { @ConfigurationComment("Do you want to allow other players to build a shop on a block where there's one already?") public static boolean ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK = false; - @ConfigurationComment("Can shops be used even when the seller doesn't have enough items? (The price will be scaled adequatly to the item amount)") + @ConfigurationComment("Can shops be used even when the seller doesn't have enough items? (The price will be scaled adequately to the item amount)") public static boolean ALLOW_PARTIAL_TRANSACTIONS = true; @ConfigurationComment("Can '?' be put in place of item name in order for the sign to be auto-filled?") @@ -79,6 +79,14 @@ public class Properties { @PrecededBySpace @ConfigurationComment("Do you want to show \"Out of stock\" messages?") public static boolean SHOW_MESSAGE_OUT_OF_STOCK = true; + @ConfigurationComment("Do you want to show \"Full shop\" messages?") + public static boolean SHOW_MESSAGE_FULL_SHOP = true; + + @PrecededBySpace + @ConfigurationComment("Can players hide the \"Out of stock\" messages with /cstoggle?") + public static boolean CSTOGGLE_TOGGLES_OUT_OF_STOCK = false; + @ConfigurationComment("Can players hide the \"Full shop\" messages with /cstoggle?") + public static boolean CSTOGGLE_TOGGLES_FULL_SHOP = false; @ConfigurationComment("Do you want to show \"You bought/sold... \" messages?") public static boolean SHOW_TRANSACTION_INFORMATION_CLIENT = true; diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PreTransaction/ErrorMessageSender.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PreTransaction/ErrorMessageSender.java index 9edd8c9..f2ff51f 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PreTransaction/ErrorMessageSender.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PreTransaction/ErrorMessageSender.java @@ -2,9 +2,11 @@ package com.Acrobot.ChestShop.Listeners.PreTransaction; import com.Acrobot.Breeze.Utils.InventoryUtil; import com.Acrobot.Breeze.Utils.MaterialUtil; +import com.Acrobot.ChestShop.Commands.Toggle; import com.Acrobot.ChestShop.Configuration.Messages; import com.Acrobot.ChestShop.Configuration.Properties; import com.Acrobot.ChestShop.Events.PreTransactionEvent; +import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -14,6 +16,7 @@ import org.bukkit.inventory.ItemStack; import static com.Acrobot.ChestShop.Configuration.Messages.CLIENT_DEPOSIT_FAILED; import static com.Acrobot.ChestShop.Configuration.Messages.NOT_ENOUGH_STOCK_IN_YOUR_SHOP; +import static com.Acrobot.ChestShop.Configuration.Messages.NOT_ENOUGH_SPACE_IN_YOUR_SHOP; /** * @author Acrobot @@ -44,6 +47,17 @@ public class ErrorMessageSender implements Listener { message = Messages.NOT_ENOUGH_MONEY_SHOP; break; case NOT_ENOUGH_SPACE_IN_CHEST: + if (Properties.SHOW_MESSAGE_FULL_SHOP && !Properties.CSTOGGLE_TOGGLES_FULL_SHOP || !Toggle.isIgnoring(event.getOwner())) { + Location loc = event.getSign().getLocation(); + String messageNotEnoughSpace = Messages.prefix(NOT_ENOUGH_SPACE_IN_YOUR_SHOP) + .replace("%material", getItemNames(event.getStock())) + .replace("%seller", event.getClient().getName()) + .replace("%world", loc.getWorld().getName()) + .replace("%x", String.valueOf(loc.getBlockX())) + .replace("%y", String.valueOf(loc.getBlockY())) + .replace("%z", String.valueOf(loc.getBlockZ())); + sendMessageToOwner(event.getOwner(), messageNotEnoughSpace); + } message = Messages.NOT_ENOUGH_SPACE_IN_CHEST; break; case NOT_ENOUGH_SPACE_IN_INVENTORY: @@ -53,10 +67,17 @@ public class ErrorMessageSender implements Listener { message = Messages.NOT_ENOUGH_ITEMS_TO_SELL; break; case NOT_ENOUGH_STOCK_IN_CHEST: - String messageOutOfStock = Messages.prefix(NOT_ENOUGH_STOCK_IN_YOUR_SHOP) - .replace("%material", getItemNames(event.getStock())) - .replace("%buyer", event.getClient().getName()); - sendMessageToOwner(event.getOwner(), messageOutOfStock); + if (Properties.SHOW_MESSAGE_OUT_OF_STOCK && !Properties.CSTOGGLE_TOGGLES_OUT_OF_STOCK || !Toggle.isIgnoring(event.getOwner())) { + Location loc = event.getSign().getLocation(); + String messageOutOfStock = Messages.prefix(NOT_ENOUGH_STOCK_IN_YOUR_SHOP) + .replace("%material", getItemNames(event.getStock())) + .replace("%buyer", event.getClient().getName()) + .replace("%world", loc.getWorld().getName()) + .replace("%x", String.valueOf(loc.getBlockX())) + .replace("%y", String.valueOf(loc.getBlockY())) + .replace("%z", String.valueOf(loc.getBlockZ())); + sendMessageToOwner(event.getOwner(), messageOutOfStock); + } message = Messages.NOT_ENOUGH_STOCK; break; case CLIENT_DEPOSIT_FAILED: @@ -85,17 +106,17 @@ public class ErrorMessageSender implements Listener { private static String getItemNames(ItemStack[] stock) { ItemStack[] items = InventoryUtil.mergeSimilarStacks(stock); - StringBuilder names = new StringBuilder(50); + StringBuilder names = new StringBuilder(MaterialUtil.getName(items[0])); - for (ItemStack item : items) { - names.append(MaterialUtil.getName(item)).append(',').append(' '); + for (int i = 1; i < items.length; i++) { + names.append(MaterialUtil.getName(items[i])).append(',').append(' '); } return names.toString(); } private static void sendMessageToOwner(OfflinePlayer owner, String message) { - if (owner.isOnline() && Properties.SHOW_MESSAGE_OUT_OF_STOCK) { + if (owner.isOnline()) { Player player = (Player) owner; player.sendMessage(message); }