package net.knarcraft.blacksmith.formatting; import static net.knarcraft.blacksmith.formatting.StringFormatter.replacePlaceholders; /** * An enum containing all translatable global messages * *
This does not include NPC messages as they are configurable per-npc, and can be translated by changing the * default message values in the main config file.
*/ public enum TranslatableMessage { VALUE_CHANGED, VALUE_FOR_ITEM_CHANGED, CURRENT_VALUE, CURRENT_VALUE_FOR_ITEM, ITEM_TYPE_ENCHANTMENT, ITEM_TYPE_MATERIAL, RAW_VALUE, NO_NPC_SELECTED, DEFAULT_REFORGE_ABLE_ITEMS_UNCHANGEABLE, INPUT_STRING_LIST_REQUIRED, INPUT_PERCENTAGE_REQUIRED, INPUT_STRING_REQUIRED, INPUT_POSITIVE_DOUBLE_REQUIRED, INPUT_POSITIVE_INTEGER_REQUIRED, PERMISSION_DENIED, PLUGIN_RELOADED; /** * Gets the message to display when displaying the raw value of messages * * @param rawValueThe raw value to display
* @returnThe message to display
*/ public static String getRawValueMessage(String rawValue) { return StringFormatter.replacePlaceholder(Translator.getTranslatedMessage(TranslatableMessage.RAW_VALUE), "{rawValue}", rawValue); } /** * Gets the message to display when a value has been changed * * @param settingThe setting whose value has been changed
* @param newValueThe new value of the setting
* @returnThe string to display to a user
*/ public static String getValueChangedMessage(String setting, String newValue) { return replacePlaceholders(Translator.getTranslatedMessage(TranslatableMessage.VALUE_CHANGED), new String[]{"{setting}", "{newValue}"}, new String[]{setting, newValue}); } /** * Gets the message to display when a value has been changed for an item * * @param settingThe setting whose value has been changed
* @param itemTypeThe type of item changed ("material" or "enchantment")
* @param itemThe item the setting was changed for (a material or an enchantment name)
* @param newValueThe new value of the setting
* @returnThe string to display to a user
*/ public static String getItemValueChangedMessage(String setting, ItemType itemType, String item, String newValue) { return replacePlaceholders(Translator.getTranslatedMessage(TranslatableMessage.VALUE_FOR_ITEM_CHANGED), new String[]{"{setting}", "{itemType}", "{item}", "{newValue}"}, new String[]{setting, itemType.getItemTypeName(), item, newValue}); } /** * Gets the message to display when displaying a setting's current value * * @param settingThe setting whose value is shown
* @param currentValueThe current value of the setting
* @returnThe string to display to a user
*/ public static String getCurrentValueMessage(String setting, String currentValue) { return replacePlaceholders(Translator.getTranslatedMessage(TranslatableMessage.CURRENT_VALUE), new String[]{"{setting}", "{currentValue}"}, new String[]{setting, currentValue}); } /** * Gets the message to display when displaying a setting's current value for an item * * @param settingThe setting whose value is shown
* @param itemTypeThe type of item shown ("material" or "enchantment")
* @param itemThe item the setting is shown for (a material or an enchantment name)
* @param currentValueThe current value of the setting
* @returnThe string to display to a user
*/ public static String getItemCurrentValueMessage(String setting, ItemType itemType, String item, String currentValue) { return replacePlaceholders(Translator.getTranslatedMessage(TranslatableMessage.CURRENT_VALUE_FOR_ITEM), new String[]{"{setting}", "{itemType}", "{item}", "{currentValue}"}, new String[]{setting, itemType.getItemTypeName(), item, currentValue}); } }