Improved configuration of command description messages

+ Renamed all occurrences of "regex" to "placeholder"
This commit is contained in:
Eric 2017-06-02 14:37:11 +02:00
parent b455db4172
commit 57e57dc71e
10 changed files with 147 additions and 128 deletions

View File

@ -324,11 +324,11 @@ public class ShopChest extends JavaPlugin {
latestVersion = uc.getVersion(); latestVersion = uc.getVersion();
downloadLink = uc.getLink(); downloadLink = uc.getLink();
isUpdateNeeded = true; isUpdateNeeded = true;
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Placeholder.VERSION, latestVersion))); Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, latestVersion)));
for (Player p : getServer().getOnlinePlayers()) { for (Player p : getServer().getOnlinePlayers()) {
if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) { if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) {
JsonBuilder jb = new JsonBuilder(ShopChest.this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Placeholder.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); JsonBuilder jb = new JsonBuilder(ShopChest.this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink);
jb.sendJson(p); jb.sendJson(p);
} }
} }

View File

@ -141,8 +141,8 @@ class ShopCommand implements CommandExecutor {
plugin.debug(p.getName() + " is viewing his shop limits: " + shopUtils.getShopAmount(p) + "/" + shopUtils.getShopLimit(p)); plugin.debug(p.getName() + " is viewing his shop limits: " + shopUtils.getShopAmount(p) + "/" + shopUtils.getShopLimit(p));
int limit = shopUtils.getShopLimit(p); int limit = shopUtils.getShopLimit(p);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OCCUPIED_SHOP_SLOTS, p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OCCUPIED_SHOP_SLOTS,
new LocalizedMessage.ReplacedRegex(Placeholder.LIMIT, (limit < 0 ? "" : String.valueOf(limit))), new LocalizedMessage.ReplacedPlaceholder(Placeholder.LIMIT, (limit < 0 ? "" : String.valueOf(limit))),
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shopUtils.getShopAmount(p))))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shopUtils.getShopAmount(p)))));
} else if (args[0].equalsIgnoreCase("open")) { } else if (args[0].equalsIgnoreCase("open")) {
needsHelp = false; needsHelp = false;
open(p); open(p);
@ -198,13 +198,13 @@ class ShopCommand implements CommandExecutor {
if (args[1].equalsIgnoreCase("set")) { if (args[1].equalsIgnoreCase("set")) {
plugin.getShopChestConfig().set(property, value); plugin.getShopChestConfig().set(property, value);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_SET, new LocalizedMessage.ReplacedRegex(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedRegex(Placeholder.VALUE, value))); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_SET, new LocalizedMessage.ReplacedPlaceholder(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedPlaceholder(Placeholder.VALUE, value)));
} else if (args[1].equalsIgnoreCase("add")) { } else if (args[1].equalsIgnoreCase("add")) {
plugin.getShopChestConfig().add(property, value); plugin.getShopChestConfig().add(property, value);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_ADDED, new LocalizedMessage.ReplacedRegex(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedRegex(Placeholder.VALUE, value))); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_ADDED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedPlaceholder(Placeholder.VALUE, value)));
} else if (args[1].equalsIgnoreCase("remove")) { } else if (args[1].equalsIgnoreCase("remove")) {
plugin.getShopChestConfig().remove(property, value); plugin.getShopChestConfig().remove(property, value);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_REMOVED, new LocalizedMessage.ReplacedRegex(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedRegex(Placeholder.VALUE, value))); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_REMOVED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedPlaceholder(Placeholder.VALUE, value)));
} else { } else {
sendBasicHelpMessage(sender); sendBasicHelpMessage(sender);
} }
@ -228,10 +228,10 @@ class ShopCommand implements CommandExecutor {
plugin.setUpdateNeeded(true); plugin.setUpdateNeeded(true);
if (sender instanceof Player) { if (sender instanceof Player) {
JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Placeholder.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink());
jb.sendJson((Player) sender); jb.sendJson((Player) sender);
} else { } else {
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Placeholder.VERSION, uc.getVersion()))); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, uc.getVersion())));
} }
} else if (result == UpdateCheckerResult.FALSE) { } else if (result == UpdateCheckerResult.FALSE) {
@ -266,7 +266,7 @@ class ShopCommand implements CommandExecutor {
public void onResult(Object result) { public void onResult(Object result) {
if (result instanceof Integer) { if (result instanceof Integer) {
int count = (int) result; int count = (int) result;
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.RELOADED_SHOPS, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(count)))); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.RELOADED_SHOPS, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(count))));
plugin.debug(sender.getName() + " has reloaded " + count + " shops"); plugin.debug(sender.getName() + " has reloaded " + count + " shops");
} }
} }
@ -291,7 +291,7 @@ class ShopCommand implements CommandExecutor {
if (limit != -1) { if (limit != -1) {
if (shopUtils.getShopAmount(p) >= limit) { if (shopUtils.getShopAmount(p) >= limit) {
if (shopType != ShopType.ADMIN || !plugin.getShopChestConfig().exclude_admin_shops) { if (shopType != ShopType.ADMIN || !plugin.getShopChestConfig().exclude_admin_shops) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_LIMIT_REACHED, new LocalizedMessage.ReplacedRegex(Placeholder.LIMIT, String.valueOf(limit)))); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_LIMIT_REACHED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.LIMIT, String.valueOf(limit))));
plugin.debug(p.getName() + " has reached the limit"); plugin.debug(p.getName() + " has reached the limit");
return; return;
} }
@ -370,7 +370,7 @@ class ShopCommand implements CommandExecutor {
if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) { if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) {
if (buyEnabled) { if (buyEnabled) {
if ((buyPrice < amount * minPrice) && (buyPrice > 0)) { if ((buyPrice < amount * minPrice) && (buyPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedRegex(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice)))); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice))));
plugin.debug(p.getName() + "'s buy price is lower than the minimum"); plugin.debug(p.getName() + "'s buy price is lower than the minimum");
return; return;
} }
@ -378,7 +378,7 @@ class ShopCommand implements CommandExecutor {
if (sellEnabled) { if (sellEnabled) {
if ((sellPrice < amount * minPrice) && (sellPrice > 0)) { if ((sellPrice < amount * minPrice) && (sellPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_LOW, new LocalizedMessage.ReplacedRegex(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice)))); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_LOW, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice))));
plugin.debug(p.getName() + "'s sell price is lower than the minimum"); plugin.debug(p.getName() + "'s sell price is lower than the minimum");
return; return;
} }
@ -400,7 +400,7 @@ class ShopCommand implements CommandExecutor {
if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) { if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) {
if (buyEnabled) { if (buyEnabled) {
if ((buyPrice > amount * maxPrice) && (buyPrice > 0)) { if ((buyPrice > amount * maxPrice) && (buyPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedRegex(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice)))); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice))));
plugin.debug(p.getName() + "'s buy price is higher than the maximum"); plugin.debug(p.getName() + "'s buy price is higher than the maximum");
return; return;
} }
@ -408,7 +408,7 @@ class ShopCommand implements CommandExecutor {
if (sellEnabled) { if (sellEnabled) {
if ((sellPrice > amount * maxPrice) && (sellPrice > 0)) { if ((sellPrice > amount * maxPrice) && (sellPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedRegex(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice)))); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice))));
plugin.debug(p.getName() + "'s sell price is higher than the maximum"); plugin.debug(p.getName() + "'s sell price is higher than the maximum");
return; return;
} }
@ -420,7 +420,7 @@ class ShopCommand implements CommandExecutor {
if (sellEnabled && buyEnabled) { if (sellEnabled && buyEnabled) {
if (plugin.getShopChestConfig().buy_greater_or_equal_sell) { if (plugin.getShopChestConfig().buy_greater_or_equal_sell) {
if (buyPrice < sellPrice) { if (buyPrice < sellPrice) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedRegex(Placeholder.MIN_PRICE, String.valueOf(sellPrice)))); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MIN_PRICE, String.valueOf(sellPrice))));
plugin.debug(p.getName() + "'s buy price is lower than the sell price"); plugin.debug(p.getName() + "'s buy price is lower than the sell price");
return; return;
} }
@ -441,7 +441,7 @@ class ShopCommand implements CommandExecutor {
double creationPrice = (shopType == ShopType.NORMAL) ? plugin.getShopChestConfig().shop_creation_price_normal : plugin.getShopChestConfig().shop_creation_price_admin; double creationPrice = (shopType == ShopType.NORMAL) ? plugin.getShopChestConfig().shop_creation_price_normal : plugin.getShopChestConfig().shop_creation_price_admin;
if (creationPrice > 0) { if (creationPrice > 0) {
if (plugin.getEconomy().getBalance(p) < creationPrice) { if (plugin.getEconomy().getBalance(p) < creationPrice) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new LocalizedMessage.ReplacedRegex(Placeholder.CREATION_PRICE, String.valueOf(creationPrice)))); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new LocalizedMessage.ReplacedPlaceholder(Placeholder.CREATION_PRICE, String.valueOf(creationPrice))));
plugin.debug(p.getName() + " can not pay the creation price"); plugin.debug(p.getName() + " can not pay the creation price");
return; return;
} }
@ -541,8 +541,8 @@ class ShopCommand implements CommandExecutor {
} }
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ALL_SHOPS_REMOVED, sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ALL_SHOPS_REMOVED,
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shops.size())), new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shops.size())),
new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, vendor.getName()))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendor.getName())));
} }
/** /**
@ -563,33 +563,35 @@ class ShopCommand implements CommandExecutor {
} }
} }
LocalizedMessage.ReplacedPlaceholder cmdPlaceholder = new LocalizedMessage.ReplacedPlaceholder(Placeholder.COMMAND, plugin.getShopChestConfig().main_command_name);
if (sender instanceof Player) { if (sender instanceof Player) {
if (sender.hasPermission(Permissions.CREATE_ADMIN)) { if (sender.hasPermission(Permissions.CREATE_ADMIN)) {
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " create <amount> <buy-price> <sell-price> [normal|admin] - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE_ADMIN, cmdPlaceholder));
} else if (receiveCreateMessage) { } else if (receiveCreateMessage) {
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " create <amount> <buy-price> <sell-price> - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE, cmdPlaceholder));
} }
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " remove - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE, cmdPlaceholder));
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " info - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_INFO)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_INFO, cmdPlaceholder));
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " limits - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, cmdPlaceholder));
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " open - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_OPEN)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_OPEN, cmdPlaceholder));
} }
if (sender.hasPermission(Permissions.REMOVE_OTHER)) { if (sender.hasPermission(Permissions.REMOVE_OTHER)) {
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " removeall <player> - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVEALL)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVEALL, cmdPlaceholder));
} }
if (sender.hasPermission(Permissions.RELOAD)) { if (sender.hasPermission(Permissions.RELOAD)) {
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " reload - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_RELOAD)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_RELOAD, cmdPlaceholder));
} }
if (sender.hasPermission(Permissions.UPDATE)) { if (sender.hasPermission(Permissions.UPDATE)) {
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " update - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_UPDATE)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_UPDATE, cmdPlaceholder));
} }
if (sender.hasPermission(Permissions.CONFIG)) { if (sender.hasPermission(Permissions.CONFIG)) {
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " config <set|add|remove> <property> <value> - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CONFIG)); sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CONFIG, cmdPlaceholder));
} }
} }

View File

@ -23,7 +23,8 @@ public enum Placeholder {
REVENUE("%REVENUE%"), REVENUE("%REVENUE%"),
GENERATION("%GENERATION%"), GENERATION("%GENERATION%"),
STOCK("%STOCK%"), STOCK("%STOCK%"),
MAX_STACK("%MAX-STACK%"); MAX_STACK("%MAX-STACK%"),
COMMAND("%COMMAND%");
private String name; private String name;

View File

@ -1076,15 +1076,16 @@ public class LanguageUtils {
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_CONFIG, langConfig.getString("message.noPermission.config", "&cYou don't have permission to change configuration values."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_CONFIG, langConfig.getString("message.noPermission.config", "&cYou don't have permission to change configuration values.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_OTHERS, langConfig.getString("message.noPermission.extend-others", "&cYou don't have permission to extend this chest."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_OTHERS, langConfig.getString("message.noPermission.extend-others", "&cYou don't have permission to extend this chest.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_PROTECTED, langConfig.getString("message.noPermission.extend-protected", "&cYou don't have permission to extend this chest to here."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_PROTECTED, langConfig.getString("message.noPermission.extend-protected", "&cYou don't have permission to extend this chest to here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE, langConfig.getString("message.commandDescription.create", "Create a shop."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE, langConfig.getString("message.commandDescription.create", "&a/%COMMAND% create <amount> <buy-price> <sell-price> - Create a shop."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE, langConfig.getString("message.commandDescription.remove", "Remove a shop."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE_ADMIN, langConfig.getString("message.commandDescription.create-admin", "&a/%COMMAND% create <amount> <buy-price> <sell-price> [normal|admin] - Create a shop."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_INFO, langConfig.getString("message.commandDescription.info", "Retrieve shop information."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE, langConfig.getString("message.commandDescription.remove", "&a/%COMMAND% remove - Remove a shop."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVEALL, langConfig.getString("message.commandDescription.removeall", "Remove all shops of a player."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_INFO, langConfig.getString("message.commandDescription.info", "&a/%COMMAND% info - Retrieve shop information."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_RELOAD, langConfig.getString("message.commandDescription.reload", "Reload shops."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVEALL, langConfig.getString("message.commandDescription.removeall", "&a/%COMMAND% removeall - Remove all shops of a player."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_UPDATE, langConfig.getString("message.commandDescription.update", "Check for Updates."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_RELOAD, langConfig.getString("message.commandDescription.reload", "&a/%COMMAND% reload - Reload shops."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, langConfig.getString("message.commandDescription.limits", "View shop limits."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_UPDATE, langConfig.getString("message.commandDescription.update", "&a/%COMMAND% update - Check for Updates."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_OPEN, langConfig.getString("message.commandDescription.open", "Open a shop."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, langConfig.getString("message.commandDescription.limits", "&a/%COMMAND% limits - View shop limits."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CONFIG, langConfig.getString("message.commandDescription.config", "Change configuration values."))); messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_OPEN, langConfig.getString("message.commandDescription.open", "&a/%COMMAND% open - Open a shop."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CONFIG, langConfig.getString("message.commandDescription.config", "&a/%COMMAND% config <set|get|remove> <property> <value> - Change configuration values."), Placeholder.COMMAND));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_SET, langConfig.getString("message.config.set", "&6Changed &a%PROPERTY% &6to &a%VALUE%&6."), Placeholder.PROPERTY, Placeholder.VALUE)); messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_SET, langConfig.getString("message.config.set", "&6Changed &a%PROPERTY% &6to &a%VALUE%&6."), Placeholder.PROPERTY, Placeholder.VALUE));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_REMOVED, langConfig.getString("message.config.removed", "&6Removed &a%VALUE% &6from &a%PROPERTY%&6."), Placeholder.PROPERTY, Placeholder.VALUE)); messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_REMOVED, langConfig.getString("message.config.removed", "&6Removed &a%VALUE% &6from &a%PROPERTY%&6."), Placeholder.PROPERTY, Placeholder.VALUE));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_ADDED, langConfig.getString("message.config.added", "&6Added &a%VALUE% &6to &a%PROPERTY%&6."), Placeholder.PROPERTY, Placeholder.VALUE)); messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_ADDED, langConfig.getString("message.config.added", "&6Added &a%VALUE% &6to &a%PROPERTY%&6."), Placeholder.PROPERTY, Placeholder.VALUE));
@ -1297,32 +1298,32 @@ public class LanguageUtils {
/** /**
* @param message Message which should be translated * @param message Message which should be translated
* @param replacedRegexes Regexes which might be required to be replaced in the message * @param replacedPlaceholders Placeholders which might be required to be replaced in the message
* @return Localized Message * @return Localized Message
*/ */
public static String getMessage(LocalizedMessage.Message message, LocalizedMessage.ReplacedRegex... replacedRegexes) { public static String getMessage(LocalizedMessage.Message message, LocalizedMessage.ReplacedPlaceholder... replacedPlaceholders) {
String _message = ChatColor.RED + "An error occurred: Message not found: " + message.toString(); String _message = ChatColor.RED + "An error occurred: Message not found: " + message.toString();
ArrayList<Placeholder> neededRegexes = new ArrayList<>(); ArrayList<Placeholder> neededPlaceholders = new ArrayList<>();
ArrayList<Placeholder> usedRegexes = new ArrayList<>(); ArrayList<Placeholder> usedPlaceholders = new ArrayList<>();
for (LocalizedMessage localizedMessage : messages) { for (LocalizedMessage localizedMessage : messages) {
if (localizedMessage.getMessage() == message) { if (localizedMessage.getMessage() == message) {
_message = localizedMessage.getLocalizedString(); _message = localizedMessage.getLocalizedString();
for (LocalizedMessage.ReplacedRegex replacedRegex : replacedRegexes) { for (LocalizedMessage.ReplacedPlaceholder replacedPlaceholder : replacedPlaceholders) {
neededRegexes.add(replacedRegex.getRegex()); neededPlaceholders.add(replacedPlaceholder.getPlaceholder());
for (int i = 0; i < localizedMessage.getRegexes().length; i++) { for (int i = 0; i < localizedMessage.getPlaceholders().length; i++) {
if (localizedMessage.getRegexes()[i] == replacedRegex.getRegex()) { if (localizedMessage.getPlaceholders()[i] == replacedPlaceholder.getPlaceholder()) {
Placeholder regex = replacedRegex.getRegex(); Placeholder placeholder = replacedPlaceholder.getPlaceholder();
String toReplace = replacedRegex.getReplace(); String toReplace = replacedPlaceholder.getReplace();
if (regex == Placeholder.BUY_PRICE || regex == Placeholder.SELL_PRICE || regex == Placeholder.MIN_PRICE || regex == Placeholder.CREATION_PRICE || regex == Placeholder.REVENUE) { if (placeholder == Placeholder.BUY_PRICE || placeholder == Placeholder.SELL_PRICE || placeholder == Placeholder.MIN_PRICE || placeholder == Placeholder.CREATION_PRICE || placeholder == Placeholder.REVENUE) {
if (!toReplace.equals(getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED))) { if (!toReplace.equals(getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED))) {
double price = Double.parseDouble(toReplace); double price = Double.parseDouble(toReplace);
toReplace = plugin.getEconomy().format(price); toReplace = plugin.getEconomy().format(price);
} }
} }
_message = _message.replace(regex.toString(), toReplace); _message = _message.replace(placeholder.toString(), toReplace);
usedRegexes.add(regex); usedPlaceholders.add(placeholder);
break; break;
} }
} }
@ -1330,10 +1331,10 @@ public class LanguageUtils {
} }
} }
if (!neededRegexes.containsAll(usedRegexes)) { if (!neededPlaceholders.containsAll(usedPlaceholders)) {
for (Placeholder regex : usedRegexes) { for (Placeholder placeholder : usedPlaceholders) {
if (!neededRegexes.contains(regex)) { if (!neededPlaceholders.contains(placeholder)) {
plugin.getLogger().warning("Placeholder '" + regex.toString() + "' was not used in message '" + message.toString() + "'"); plugin.getLogger().warning("Placeholder '" + placeholder.toString() + "' was not used in message '" + message.toString() + "'");
} }
} }
} }

View File

@ -6,12 +6,12 @@ import org.bukkit.ChatColor;
public class LocalizedMessage { public class LocalizedMessage {
private Message message; private Message message;
private Placeholder[] regexes; private Placeholder[] placeholders;
private String localizedString; private String localizedString;
public LocalizedMessage(Message message, String localizedString, Placeholder... regexes) { public LocalizedMessage(Message message, String localizedString, Placeholder... placeholders) {
this.message = message; this.message = message;
this.regexes = regexes; this.placeholders = placeholders;
this.localizedString = ChatColor.translateAlternateColorCodes('&', localizedString); this.localizedString = ChatColor.translateAlternateColorCodes('&', localizedString);
} }
@ -30,8 +30,8 @@ public class LocalizedMessage {
/** /**
* @return Array of {@link Placeholder}, which are required by the message * @return Array of {@link Placeholder}, which are required by the message
*/ */
public Placeholder[] getRegexes() { public Placeholder[] getPlaceholders() {
return regexes; return placeholders;
} }
/** /**
@ -122,6 +122,7 @@ public class LocalizedMessage {
NO_PERMISSION_EXTEND_OTHERS, NO_PERMISSION_EXTEND_OTHERS,
NO_PERMISSION_EXTEND_PROTECTED, NO_PERMISSION_EXTEND_PROTECTED,
COMMAND_DESC_CREATE, COMMAND_DESC_CREATE,
COMMAND_DESC_CREATE_ADMIN,
COMMAND_DESC_REMOVE, COMMAND_DESC_REMOVE,
COMMAND_DESC_INFO, COMMAND_DESC_INFO,
COMMAND_DESC_REMOVEALL, COMMAND_DESC_REMOVEALL,
@ -135,18 +136,18 @@ public class LocalizedMessage {
CHANGED_CONFIG_ADDED CHANGED_CONFIG_ADDED
} }
public static class ReplacedRegex { public static class ReplacedPlaceholder {
private Placeholder regex; private Placeholder placeholder;
private String replace; private String replace;
public ReplacedRegex(Placeholder regex, String replace) { public ReplacedPlaceholder(Placeholder placeholder, String replace) {
this.regex = regex; this.placeholder = placeholder;
this.replace = replace; this.replace = replace;
} }
/** /**
* @return String which will replace the regex * @return String which will replace the placeholder
*/ */
public String getReplace() { public String getReplace() {
return replace; return replace;
@ -155,8 +156,8 @@ public class LocalizedMessage {
/** /**
* @return Placeholder that will be replaced * @return Placeholder that will be replaced
*/ */
public Placeholder getRegex() { public Placeholder getPlaceholder() {
return regex; return placeholder;
} }
} }

View File

@ -27,7 +27,7 @@ public class NotifyPlayerOnJoinListener implements Listener {
if (plugin.isUpdateNeeded()) { if (plugin.isUpdateNeeded()) {
if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) { if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) {
JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Placeholder.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink());
jb.sendJson(p); jb.sendJson(p);
} }
} }
@ -39,7 +39,7 @@ public class NotifyPlayerOnJoinListener implements Listener {
long lastLogout = (long) result; long lastLogout = (long) result;
if (lastLogout < 0) { if (lastLogout < 0) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED,
new LocalizedMessage.ReplacedRegex(Placeholder.ERROR, "Could not get last time you logged out"))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, "Could not get last time you logged out")));
return; return;
} }
@ -50,7 +50,7 @@ public class NotifyPlayerOnJoinListener implements Listener {
double revenue = (double) result; double revenue = (double) result;
if (revenue != 0) { if (revenue != 0) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.REVENUE_WHILE_OFFLINE, p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.REVENUE_WHILE_OFFLINE,
new LocalizedMessage.ReplacedRegex(Placeholder.REVENUE, String.valueOf(revenue)))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.REVENUE, String.valueOf(revenue))));
} }
} }
} }

View File

@ -459,8 +459,8 @@ public class ShopInteractListener implements Listener {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OUT_OF_STOCK)); p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OUT_OF_STOCK));
if (shop.getVendor().isOnline() && config.enable_vendor_messages) { if (shop.getVendor().isOnline() && config.enable_vendor_messages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.VENDOR_OUT_OF_STOCK, shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.VENDOR_OUT_OF_STOCK,
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())), new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct())))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct()))));
} }
plugin.debug("Shop is out of stock"); plugin.debug("Shop is out of stock");
} }
@ -644,7 +644,7 @@ public class ShopInteractListener implements Listener {
EconomyResponse r = plugin.getEconomy().withdrawPlayer(executor, location.getWorld().getName(), creationPrice); EconomyResponse r = plugin.getEconomy().withdrawPlayer(executor, location.getWorld().getName(), creationPrice);
if (!r.transactionSuccess()) { if (!r.transactionSuccess()) {
plugin.debug("Economy transaction failed: " + r.errorMessage); plugin.debug("Economy transaction failed: " + r.errorMessage);
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedRegex(Placeholder.ERROR, r.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage)));
return; return;
} }
@ -705,7 +705,7 @@ public class ShopInteractListener implements Listener {
executor.openInventory(shop.getInventoryHolder().getInventory()); executor.openInventory(shop.getInventoryHolder().getInventory());
plugin.debug("Opened shop (#" + shop.getID() + ")"); plugin.debug("Opened shop (#" + shop.getID() + ")");
if (message) executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OPENED_SHOP, new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, shop.getVendor().getName()))); if (message) executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OPENED_SHOP, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, shop.getVendor().getName())));
} }
/** /**
@ -732,11 +732,11 @@ public class ShopInteractListener implements Listener {
shop.getVendor().getUniqueId().toString() : shop.getVendor().getName()); shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
String vendorString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_VENDOR, String vendorString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_VENDOR,
new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, vendorName)); new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName));
String productString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRODUCT, String productString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRODUCT,
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())), new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct()))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct())));
String enchantmentString = ""; String enchantmentString = "";
String potionEffectString = ""; String potionEffectString = "";
@ -746,14 +746,14 @@ public class ShopInteractListener implements Listener {
String disabled = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED); String disabled = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED);
String priceString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRICE, String priceString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRICE,
new LocalizedMessage.ReplacedRegex(Placeholder.BUY_PRICE, (shop.getBuyPrice() > 0 ? String.valueOf(shop.getBuyPrice()) : disabled)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, (shop.getBuyPrice() > 0 ? String.valueOf(shop.getBuyPrice()) : disabled)),
new LocalizedMessage.ReplacedRegex(Placeholder.SELL_PRICE, (shop.getSellPrice() > 0 ? String.valueOf(shop.getSellPrice()) : disabled))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, (shop.getSellPrice() > 0 ? String.valueOf(shop.getSellPrice()) : disabled)));
String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ? String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ?
LocalizedMessage.Message.SHOP_INFO_NORMAL : LocalizedMessage.Message.SHOP_INFO_ADMIN); LocalizedMessage.Message.SHOP_INFO_NORMAL : LocalizedMessage.Message.SHOP_INFO_ADMIN);
String stock = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, String stock = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_STOCK,
new LocalizedMessage.ReplacedRegex(Placeholder.STOCK, String.valueOf(amount))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.STOCK, String.valueOf(amount)));
String potionEffectName = LanguageUtils.getPotionEffectName(shop.getProduct()); String potionEffectName = LanguageUtils.getPotionEffectName(shop.getProduct());
@ -762,8 +762,8 @@ public class ShopInteractListener implements Listener {
String extended = potionExtended ? LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_EXTENDED) : ""; String extended = potionExtended ? LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_EXTENDED) : "";
potionEffectString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT, potionEffectString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT,
new LocalizedMessage.ReplacedRegex(Placeholder.POTION_EFFECT, potionEffectName), new LocalizedMessage.ReplacedPlaceholder(Placeholder.POTION_EFFECT, potionEffectName),
new LocalizedMessage.ReplacedRegex(Placeholder.EXTENDED, extended)); new LocalizedMessage.ReplacedPlaceholder(Placeholder.EXTENDED, extended));
} }
if (type == Material.WRITTEN_BOOK) { if (type == Material.WRITTEN_BOOK) {
@ -782,13 +782,13 @@ public class ShopInteractListener implements Listener {
} }
bookGenerationString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_BOOK_GENERATION, bookGenerationString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_BOOK_GENERATION,
new LocalizedMessage.ReplacedRegex(Placeholder.GENERATION, LanguageUtils.getBookGenerationName(generation))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.GENERATION, LanguageUtils.getBookGenerationName(generation)));
} }
String musicDiscName = LanguageUtils.getMusicDiscName(type); String musicDiscName = LanguageUtils.getMusicDiscName(type);
if (musicDiscName.length() > 0) { if (musicDiscName.length() > 0) {
musicDiscTitleString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_MUSIC_TITLE, musicDiscTitleString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_MUSIC_TITLE,
new LocalizedMessage.ReplacedRegex(Placeholder.MUSIC_TITLE, musicDiscName)); new LocalizedMessage.ReplacedPlaceholder(Placeholder.MUSIC_TITLE, musicDiscName));
} }
Map<Enchantment, Integer> enchantmentMap = ItemUtils.getEnchantments(shop.getProduct()); Map<Enchantment, Integer> enchantmentMap = ItemUtils.getEnchantments(shop.getProduct());
@ -796,7 +796,7 @@ public class ShopInteractListener implements Listener {
if (enchantmentList.length() > 0) { if (enchantmentList.length() > 0) {
enchantmentString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_ENCHANTMENTS, enchantmentString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_ENCHANTMENTS,
new LocalizedMessage.ReplacedRegex(Placeholder.ENCHANTMENT, enchantmentList)); new LocalizedMessage.ReplacedPlaceholder(Placeholder.ENCHANTMENT, enchantmentList));
} }
executor.sendMessage(" "); executor.sendMessage(" ");
@ -905,21 +905,21 @@ public class ShopInteractListener implements Listener {
executor.updateInventory(); executor.updateInventory();
String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName()); String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCCESS, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCCESS, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.BUY_PRICE, String.valueOf(newPrice)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, vendorName))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
if (shop.getVendor().isOnline() && config.enable_vendor_messages) { if (shop.getVendor().isOnline() && config.enable_vendor_messages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_BOUGHT, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)), shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_BOUGHT, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.BUY_PRICE, String.valueOf(newPrice)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.PLAYER, executor.getName()))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.PLAYER, executor.getName())));
} }
} else { } else {
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedRegex(Placeholder.ERROR, r2.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage)));
econ.depositPlayer(executor, newPrice); econ.depositPlayer(executor, newPrice);
} }
} else { } else {
@ -936,14 +936,14 @@ public class ShopInteractListener implements Listener {
addToInventory(inventory, newProduct); addToInventory(inventory, newProduct);
executor.updateInventory(); executor.updateInventory();
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCESS_ADMIN, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCESS_ADMIN, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.BUY_PRICE, String.valueOf(newPrice)))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice))));
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
} }
} else { } else {
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedRegex(Placeholder.ERROR, r.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage)));
} }
} else { } else {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE)); executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE));
@ -1044,21 +1044,21 @@ public class ShopInteractListener implements Listener {
executor.updateInventory(); executor.updateInventory();
String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName()); String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCESS, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCESS, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.SELL_PRICE, String.valueOf(newPrice)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, vendorName))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
if (shop.getVendor().isOnline() && config.enable_vendor_messages) { if (shop.getVendor().isOnline() && config.enable_vendor_messages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_SOLD, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)), shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_SOLD, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.SELL_PRICE, String.valueOf(newPrice)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.PLAYER, executor.getName()))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.PLAYER, executor.getName())));
} }
} else { } else {
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedRegex(Placeholder.ERROR, r2.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage)));
econ.withdrawPlayer(executor, newPrice); econ.withdrawPlayer(executor, newPrice);
} }
@ -1076,15 +1076,15 @@ public class ShopInteractListener implements Listener {
removeFromInventory(executor.getInventory(), newProduct); removeFromInventory(executor.getInventory(), newProduct);
executor.updateInventory(); executor.updateInventory();
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCESS_ADMIN, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCESS_ADMIN, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.SELL_PRICE, String.valueOf(newPrice)))); new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice))));
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
} }
} else { } else {
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedRegex(Placeholder.ERROR, r.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage)));
} }
} else { } else {

View File

@ -214,10 +214,10 @@ public class Shop {
for (int i = 0; i < lineCount; i++) { for (int i = 0; i < lineCount; i++) {
String format = plugin.getHologramFormat().getFormat(i, requirements, placeholders); String format = plugin.getHologramFormat().getFormat(i, requirements, placeholders);
for (Placeholder regex : placeholders.keySet()) { for (Placeholder placeholder : placeholders.keySet()) {
String replace = ""; String replace = "";
switch (regex) { switch (placeholder) {
case BUY_PRICE: case BUY_PRICE:
replace = plugin.getEconomy().format(getBuyPrice()); replace = plugin.getEconomy().format(getBuyPrice());
break; break;
@ -225,10 +225,10 @@ public class Shop {
replace = plugin.getEconomy().format(getSellPrice()); replace = plugin.getEconomy().format(getSellPrice());
break; break;
default: default:
replace = String.valueOf(placeholders.get(regex)); replace = String.valueOf(placeholders.get(placeholder));
} }
format = format.replace(regex.toString(), replace); format = format.replace(placeholder.toString(), replace);
} }
if (!format.isEmpty()) { if (!format.isEmpty()) {

View File

@ -77,15 +77,16 @@ message.noPermission.update=&cDu hast keine Berechtigung nach Aktualisierungen z
message.noPermission.config=&cDu hast keine Berechtigung Konfigurationswerte zu verändern. message.noPermission.config=&cDu hast keine Berechtigung Konfigurationswerte zu verändern.
message.noPermission.extend-others=&cDu hast keine Berechtigung diesen Shop zu erweitern. message.noPermission.extend-others=&cDu hast keine Berechtigung diesen Shop zu erweitern.
message.noPermission.extend-protected=&cDu hast keine Berechtigung diesen Shop nach hier zu erweitern. message.noPermission.extend-protected=&cDu hast keine Berechtigung diesen Shop nach hier zu erweitern.
message.commandDescription.create=Erstelle einen Shop. message.commandDescription.create=&a/%COMMAND% create <amount> <buy-price> <sell-price> - Erstelle einen Shop.
message.commandDescription.remove=Entferne einen Shop. message.commandDescription.create-admin=&a/%COMMAND% create <amount> <buy-price> <sell-price> [normal|admin] - Erstelle einen Shop.
message.commandDescription.info=Rufe Informationen über den Shop ab. message.commandDescription.remove=&a/%COMMAND% remove - Entferne einen Shop.
message.commandDescription.removeall=Entferne alle Shops eines Spielers. message.commandDescription.info=&a/%COMMAND% info - Rufe Informationen über den Shop ab.
message.commandDescription.reload=Lade die Shops neu. message.commandDescription.removeall=&a/%COMMAND% removeall - Entferne alle Shops eines Spielers.
message.commandDescription.update=Suche nach Aktualisierungen. message.commandDescription.reload=&a/%COMMAND% reload - Lade die Shops neu.
message.commandDescription.limits=Betrachte die Shop Limits. message.commandDescription.update=&a/%COMMAND% update - Suche nach Aktualisierungen.
message.commandDescription.open=Öffne einen Shop. message.commandDescription.limits=&a/%COMMAND% limits - Betrachte die Shop Limits.
message.commandDescription.config=Verändere Konfigurationswerte. message.commandDescription.open=&a/%COMMAND% open - Öffne einen Shop.
message.commandDescription.config=&a/%COMMAND% config <set|get|remove> <property> <value> - Verändere Konfigurationswerte.
message.config.set=&6Eigenschaft &a%PROPERTY% &6wurde auf &a%VALUE% &6gesetzt. message.config.set=&6Eigenschaft &a%PROPERTY% &6wurde auf &a%VALUE% &6gesetzt.
message.config.added=&6Wert &a%VALUE% &6wurde zu &a%PROPERTY% &6hinzugefügt. message.config.added=&6Wert &a%VALUE% &6wurde zu &a%PROPERTY% &6hinzugefügt.
message.config.removed=&6Wert &a%VALUE% &6wurde aus &a%PROPERTY% &6entfernt. message.config.removed=&6Wert &a%VALUE% &6wurde aus &a%PROPERTY% &6entfernt.

View File

@ -268,31 +268,44 @@ message.noPermission.extend-others=&cYou don't have permission to extend this ch
message.noPermission.extend-protected=&cYou don't have permission to extend this chest to here. message.noPermission.extend-protected=&cYou don't have permission to extend this chest to here.
# Set the command description message for '/shop create' when you type '/shop'. # Set the command description message for '/shop create' when you type '/shop'.
message.commandDescription.create=Create a shop. # Usable Placeholders: %COMMAND%
message.commandDescription.create=&a/%COMMAND% create <amount> <buy-price> <sell-price> - Create a shop.
# Set the command description message for '/shop create' when you type '/shop' and have permission "shopchest.create.admin"
# Usable Placeholders: %COMMAND%
message.commandDescription.create-admin=&a/%COMMAND% create <amount> <buy-price> <sell-price> [normal|admin] - Create a shop.
# Set the command description message for '/shop remove' when you type '/shop'. # Set the command description message for '/shop remove' when you type '/shop'.
message.commandDescription.remove=Remove a shop. # Usable Placeholders: %COMMAND%
message.commandDescription.remove=&a/%COMMAND% remove - Remove a shop.
# Set the command description message for '/shop info' when you type '/shop'. # Set the command description message for '/shop info' when you type '/shop'.
message.commandDescription.info=Retrieve shop information. # Usable Placeholders: %COMMAND%
message.commandDescription.info=&a/%COMMAND% info - Retrieve shop information.
# Set the command description message for '/shop removeall' when you type '/shop'. # Set the command description message for '/shop removeall' when you type '/shop'.
message.commandDescription.removeall=Remove all shops of a player. # Usable Placeholders: %COMMAND%
message.commandDescription.removeall=&a/%COMMAND% removeall - Remove all shops of a player.
# Set the command description message for '/shop reload' when you type '/shop'. # Set the command description message for '/shop reload' when you type '/shop'.
message.commandDescription.reload=Reload shops. # Usable Placeholders: %COMMAND%
message.commandDescription.reload=&a/%COMMAND% reload - Reload shops.
# Set the command description message for '/shop update' when you type '/shop'. # Set the command description message for '/shop update' when you type '/shop'.
message.commandDescription.update=Check for Updates. # Usable Placeholders: %COMMAND%
message.commandDescription.update=&a%/%COMMAND% update - Check for Updates.
# Set the command description message for '/shop limits' when you type '/shop'. # Set the command description message for '/shop limits' when you type '/shop'.
message.commandDescription.limits=View shop limits. # Usable Placeholders: %COMMAND%
message.commandDescription.limits=&a/%COMMAND% limits - View shop limits.
# Set the command description message for '/shop open' when you type '/shop'. # Set the command description message for '/shop open' when you type '/shop'.
message.commandDescription.open=Open a shop. # Usable Placeholders: %COMMAND%
message.commandDescription.open=&a/%COMMAND% open - Open a shop.
# Set the command description message for '/shop config' when you type '/shop'. # Set the command description message for '/shop config' when you type '/shop'.
message.commandDescription.config=Change configuration values. # Usable Placeholders: %COMMAND%
message.commandDescription.config=&a/%COMMAND% config <set|add|remove> <property> <value> - Change configuration values.
# Set the message a player gets after setting a configuration value per command # Set the message a player gets after setting a configuration value per command
# Usable Placeholders: %PROPERTY%, %VALUE% # Usable Placeholders: %PROPERTY%, %VALUE%