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();
downloadLink = uc.getLink();
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()) {
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);
}
}

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));
int limit = shopUtils.getShopLimit(p);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OCCUPIED_SHOP_SLOTS,
new LocalizedMessage.ReplacedRegex(Placeholder.LIMIT, (limit < 0 ? "" : String.valueOf(limit))),
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shopUtils.getShopAmount(p)))));
new LocalizedMessage.ReplacedPlaceholder(Placeholder.LIMIT, (limit < 0 ? "" : String.valueOf(limit))),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shopUtils.getShopAmount(p)))));
} else if (args[0].equalsIgnoreCase("open")) {
needsHelp = false;
open(p);
@ -198,13 +198,13 @@ class ShopCommand implements CommandExecutor {
if (args[1].equalsIgnoreCase("set")) {
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")) {
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")) {
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 {
sendBasicHelpMessage(sender);
}
@ -228,10 +228,10 @@ class ShopCommand implements CommandExecutor {
plugin.setUpdateNeeded(true);
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);
} 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) {
@ -266,7 +266,7 @@ class ShopCommand implements CommandExecutor {
public void onResult(Object result) {
if (result instanceof Integer) {
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");
}
}
@ -291,7 +291,7 @@ class ShopCommand implements CommandExecutor {
if (limit != -1) {
if (shopUtils.getShopAmount(p) >= limit) {
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");
return;
}
@ -370,7 +370,7 @@ class ShopCommand implements CommandExecutor {
if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) {
if (buyEnabled) {
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");
return;
}
@ -378,7 +378,7 @@ class ShopCommand implements CommandExecutor {
if (sellEnabled) {
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");
return;
}
@ -400,7 +400,7 @@ class ShopCommand implements CommandExecutor {
if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) {
if (buyEnabled) {
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");
return;
}
@ -408,7 +408,7 @@ class ShopCommand implements CommandExecutor {
if (sellEnabled) {
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");
return;
}
@ -420,7 +420,7 @@ class ShopCommand implements CommandExecutor {
if (sellEnabled && buyEnabled) {
if (plugin.getShopChestConfig().buy_greater_or_equal_sell) {
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");
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;
if (creationPrice > 0) {
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");
return;
}
@ -541,8 +541,8 @@ class ShopCommand implements CommandExecutor {
}
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ALL_SHOPS_REMOVED,
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shops.size())),
new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, vendor.getName())));
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shops.size())),
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.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) {
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(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " info - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_INFO));
sender.sendMessage(ChatColor.GREEN + "/" + plugin.getShopChestConfig().main_command_name + " limits - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS));
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_REMOVE, cmdPlaceholder));
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_INFO, cmdPlaceholder));
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, cmdPlaceholder));
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_OPEN, cmdPlaceholder));
}
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)) {
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)) {
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)) {
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%"),
GENERATION("%GENERATION%"),
STOCK("%STOCK%"),
MAX_STACK("%MAX-STACK%");
MAX_STACK("%MAX-STACK%"),
COMMAND("%COMMAND%");
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_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.COMMAND_DESC_CREATE, langConfig.getString("message.commandDescription.create", "Create a shop.")));
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_INFO, langConfig.getString("message.commandDescription.info", "Retrieve shop information.")));
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_RELOAD, langConfig.getString("message.commandDescription.reload", "Reload shops.")));
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_LIMITS, langConfig.getString("message.commandDescription.limits", "View shop limits.")));
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_CONFIG, langConfig.getString("message.commandDescription.config", "Change configuration values.")));
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_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_REMOVE, langConfig.getString("message.commandDescription.remove", "&a/%COMMAND% remove - Remove a shop."), Placeholder.COMMAND));
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_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_RELOAD, langConfig.getString("message.commandDescription.reload", "&a/%COMMAND% reload - Reload shops."), Placeholder.COMMAND));
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_LIMITS, langConfig.getString("message.commandDescription.limits", "&a/%COMMAND% limits - View shop limits."), Placeholder.COMMAND));
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_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));
@ -1297,32 +1298,32 @@ public class LanguageUtils {
/**
* @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
*/
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();
ArrayList<Placeholder> neededRegexes = new ArrayList<>();
ArrayList<Placeholder> usedRegexes = new ArrayList<>();
ArrayList<Placeholder> neededPlaceholders = new ArrayList<>();
ArrayList<Placeholder> usedPlaceholders = new ArrayList<>();
for (LocalizedMessage localizedMessage : messages) {
if (localizedMessage.getMessage() == message) {
_message = localizedMessage.getLocalizedString();
for (LocalizedMessage.ReplacedRegex replacedRegex : replacedRegexes) {
neededRegexes.add(replacedRegex.getRegex());
for (int i = 0; i < localizedMessage.getRegexes().length; i++) {
if (localizedMessage.getRegexes()[i] == replacedRegex.getRegex()) {
Placeholder regex = replacedRegex.getRegex();
String toReplace = replacedRegex.getReplace();
if (regex == Placeholder.BUY_PRICE || regex == Placeholder.SELL_PRICE || regex == Placeholder.MIN_PRICE || regex == Placeholder.CREATION_PRICE || regex == Placeholder.REVENUE) {
for (LocalizedMessage.ReplacedPlaceholder replacedPlaceholder : replacedPlaceholders) {
neededPlaceholders.add(replacedPlaceholder.getPlaceholder());
for (int i = 0; i < localizedMessage.getPlaceholders().length; i++) {
if (localizedMessage.getPlaceholders()[i] == replacedPlaceholder.getPlaceholder()) {
Placeholder placeholder = replacedPlaceholder.getPlaceholder();
String toReplace = replacedPlaceholder.getReplace();
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))) {
double price = Double.parseDouble(toReplace);
toReplace = plugin.getEconomy().format(price);
}
}
_message = _message.replace(regex.toString(), toReplace);
usedRegexes.add(regex);
_message = _message.replace(placeholder.toString(), toReplace);
usedPlaceholders.add(placeholder);
break;
}
}
@ -1330,10 +1331,10 @@ public class LanguageUtils {
}
}
if (!neededRegexes.containsAll(usedRegexes)) {
for (Placeholder regex : usedRegexes) {
if (!neededRegexes.contains(regex)) {
plugin.getLogger().warning("Placeholder '" + regex.toString() + "' was not used in message '" + message.toString() + "'");
if (!neededPlaceholders.containsAll(usedPlaceholders)) {
for (Placeholder placeholder : usedPlaceholders) {
if (!neededPlaceholders.contains(placeholder)) {
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 {
private Message message;
private Placeholder[] regexes;
private Placeholder[] placeholders;
private String localizedString;
public LocalizedMessage(Message message, String localizedString, Placeholder... regexes) {
public LocalizedMessage(Message message, String localizedString, Placeholder... placeholders) {
this.message = message;
this.regexes = regexes;
this.placeholders = placeholders;
this.localizedString = ChatColor.translateAlternateColorCodes('&', localizedString);
}
@ -30,8 +30,8 @@ public class LocalizedMessage {
/**
* @return Array of {@link Placeholder}, which are required by the message
*/
public Placeholder[] getRegexes() {
return regexes;
public Placeholder[] getPlaceholders() {
return placeholders;
}
/**
@ -122,6 +122,7 @@ public class LocalizedMessage {
NO_PERMISSION_EXTEND_OTHERS,
NO_PERMISSION_EXTEND_PROTECTED,
COMMAND_DESC_CREATE,
COMMAND_DESC_CREATE_ADMIN,
COMMAND_DESC_REMOVE,
COMMAND_DESC_INFO,
COMMAND_DESC_REMOVEALL,
@ -135,18 +136,18 @@ public class LocalizedMessage {
CHANGED_CONFIG_ADDED
}
public static class ReplacedRegex {
public static class ReplacedPlaceholder {
private Placeholder regex;
private Placeholder placeholder;
private String replace;
public ReplacedRegex(Placeholder regex, String replace) {
this.regex = regex;
public ReplacedPlaceholder(Placeholder placeholder, String replace) {
this.placeholder = placeholder;
this.replace = replace;
}
/**
* @return String which will replace the regex
* @return String which will replace the placeholder
*/
public String getReplace() {
return replace;
@ -155,8 +156,8 @@ public class LocalizedMessage {
/**
* @return Placeholder that will be replaced
*/
public Placeholder getRegex() {
return regex;
public Placeholder getPlaceholder() {
return placeholder;
}
}

View File

@ -27,7 +27,7 @@ public class NotifyPlayerOnJoinListener implements Listener {
if (plugin.isUpdateNeeded()) {
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);
}
}
@ -39,7 +39,7 @@ public class NotifyPlayerOnJoinListener implements Listener {
long lastLogout = (long) result;
if (lastLogout < 0) {
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;
}
@ -50,7 +50,7 @@ public class NotifyPlayerOnJoinListener implements Listener {
double revenue = (double) result;
if (revenue != 0) {
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));
if (shop.getVendor().isOnline() && config.enable_vendor_messages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.VENDOR_OUT_OF_STOCK,
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct()))));
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct()))));
}
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);
if (!r.transactionSuccess()) {
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;
}
@ -705,7 +705,7 @@ public class ShopInteractListener implements Listener {
executor.openInventory(shop.getInventoryHolder().getInventory());
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());
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,
new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct())));
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct())));
String enchantmentString = "";
String potionEffectString = "";
@ -746,14 +746,14 @@ public class ShopInteractListener implements Listener {
String disabled = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED);
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.ReplacedRegex(Placeholder.SELL_PRICE, (shop.getSellPrice() > 0 ? String.valueOf(shop.getSellPrice()) : disabled)));
new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, (shop.getBuyPrice() > 0 ? String.valueOf(shop.getBuyPrice()) : disabled)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, (shop.getSellPrice() > 0 ? String.valueOf(shop.getSellPrice()) : disabled)));
String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ?
LocalizedMessage.Message.SHOP_INFO_NORMAL : LocalizedMessage.Message.SHOP_INFO_ADMIN);
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());
@ -762,8 +762,8 @@ public class ShopInteractListener implements Listener {
String extended = potionExtended ? LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_EXTENDED) : "";
potionEffectString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT,
new LocalizedMessage.ReplacedRegex(Placeholder.POTION_EFFECT, potionEffectName),
new LocalizedMessage.ReplacedRegex(Placeholder.EXTENDED, extended));
new LocalizedMessage.ReplacedPlaceholder(Placeholder.POTION_EFFECT, potionEffectName),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.EXTENDED, extended));
}
if (type == Material.WRITTEN_BOOK) {
@ -782,13 +782,13 @@ public class ShopInteractListener implements Listener {
}
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);
if (musicDiscName.length() > 0) {
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());
@ -796,7 +796,7 @@ public class ShopInteractListener implements Listener {
if (enchantmentList.length() > 0) {
enchantmentString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_ENCHANTMENTS,
new LocalizedMessage.ReplacedRegex(Placeholder.ENCHANTMENT, enchantmentList));
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ENCHANTMENT, enchantmentList));
}
executor.sendMessage(" ");
@ -905,21 +905,21 @@ public class ShopInteractListener implements Listener {
executor.updateInventory();
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)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, vendorName)));
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCCESS, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
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)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.PLAYER, executor.getName())));
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_BOUGHT, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.PLAYER, executor.getName())));
}
} else {
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);
}
} else {
@ -936,14 +936,14 @@ public class ShopInteractListener implements Listener {
addToInventory(inventory, newProduct);
executor.updateInventory();
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCESS_ADMIN, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.BUY_PRICE, String.valueOf(newPrice))));
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCESS_ADMIN, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
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() + ")");
}
} else {
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 {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE));
@ -1044,21 +1044,21 @@ public class ShopInteractListener implements Listener {
executor.updateInventory();
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)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.VENDOR, vendorName)));
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCESS, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
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)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedRegex(Placeholder.PLAYER, executor.getName())));
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_SOLD, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.PLAYER, executor.getName())));
}
} else {
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);
}
@ -1076,15 +1076,15 @@ public class ShopInteractListener implements Listener {
removeFromInventory(executor.getInventory(), newProduct);
executor.updateInventory();
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCESS_ADMIN, new LocalizedMessage.ReplacedRegex(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedRegex(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedRegex(Placeholder.SELL_PRICE, String.valueOf(newPrice))));
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCESS_ADMIN, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)),
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() + ")");
}
} else {
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 {

View File

@ -214,10 +214,10 @@ public class Shop {
for (int i = 0; i < lineCount; i++) {
String format = plugin.getHologramFormat().getFormat(i, requirements, placeholders);
for (Placeholder regex : placeholders.keySet()) {
for (Placeholder placeholder : placeholders.keySet()) {
String replace = "";
switch (regex) {
switch (placeholder) {
case BUY_PRICE:
replace = plugin.getEconomy().format(getBuyPrice());
break;
@ -225,10 +225,10 @@ public class Shop {
replace = plugin.getEconomy().format(getSellPrice());
break;
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()) {

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.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.commandDescription.create=Erstelle einen Shop.
message.commandDescription.remove=Entferne einen Shop.
message.commandDescription.info=Rufe Informationen über den Shop ab.
message.commandDescription.removeall=Entferne alle Shops eines Spielers.
message.commandDescription.reload=Lade die Shops neu.
message.commandDescription.update=Suche nach Aktualisierungen.
message.commandDescription.limits=Betrachte die Shop Limits.
message.commandDescription.open=Öffne einen Shop.
message.commandDescription.config=Verändere Konfigurationswerte.
message.commandDescription.create=&a/%COMMAND% create <amount> <buy-price> <sell-price> - Erstelle einen Shop.
message.commandDescription.create-admin=&a/%COMMAND% create <amount> <buy-price> <sell-price> [normal|admin] - Erstelle einen Shop.
message.commandDescription.remove=&a/%COMMAND% remove - Entferne einen Shop.
message.commandDescription.info=&a/%COMMAND% info - Rufe Informationen über den Shop ab.
message.commandDescription.removeall=&a/%COMMAND% removeall - Entferne alle Shops eines Spielers.
message.commandDescription.reload=&a/%COMMAND% reload - Lade die Shops neu.
message.commandDescription.update=&a/%COMMAND% update - Suche nach Aktualisierungen.
message.commandDescription.limits=&a/%COMMAND% limits - Betrachte die Shop Limits.
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.added=&6Wert &a%VALUE% &6wurde zu &a%PROPERTY% &6hinzugefügt.
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.
# 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'.
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'.
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'.
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'.
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'.
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'.
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'.
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'.
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
# Usable Placeholders: %PROPERTY%, %VALUE%