Blacksmith/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithTranslatableMessage.java

209 lines
7.2 KiB
Java

package net.knarcraft.blacksmith.formatting;
import net.knarcraft.blacksmith.BlacksmithPlugin;
import net.knarcraft.knarlib.formatting.StringFormatter;
import net.knarcraft.knarlib.formatting.TranslatableMessage;
/**
* An enum containing all translatable global messages
*
* <p>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.</p>
*/
public enum BlacksmithTranslatableMessage implements TranslatableMessage {
/**
* The message displayed when a configuration value has been successfully changed
*/
VALUE_CHANGED,
/**
* The message displayed when a configuration value for one material or enchantment has been successfully changed
*/
VALUE_FOR_ITEM_CHANGED,
/**
* The message displayed when showing the current value of a configuration option
*/
CURRENT_VALUE,
/**
* The message displayed when showing the current value of a configuration option for one material or enchantment
*/
CURRENT_VALUE_FOR_ITEM,
/**
* The translation of enchantment
*/
ITEM_TYPE_ENCHANTMENT,
/**
* The translation of material
*/
ITEM_TYPE_MATERIAL,
/**
* The message displayed when showing the "raw" value of messages
*/
RAW_VALUE,
/**
* The message displayed when trying to change a blacksmith value before selecting a blacksmith
*/
NO_NPC_SELECTED,
/**
* The message displayed if a string list is required, but something else is given
*/
INPUT_STRING_LIST_REQUIRED,
/**
* The message displayed if a value between 0 and 100 is required, but something else is given
*/
INPUT_PERCENTAGE_REQUIRED,
/**
* The message displayed if a string is required, but something else is given
*/
INPUT_STRING_REQUIRED,
/**
* The message displayed if a positive double is required, but something else is given
*/
INPUT_POSITIVE_DOUBLE_REQUIRED,
/**
* The message displayed if a positive integer is required, but something else is given
*/
INPUT_POSITIVE_INTEGER_REQUIRED,
/**
* The message displayed if a player is missing the required permission for an action
*/
PERMISSION_DENIED,
/**
* The message displayed if this plugin is successfully reloaded
*/
PLUGIN_RELOADED,
/**
* The message displayed if a filter is specified which isn't supported by the specified preset
*/
INVALID_FILTER_FOR_PRESET,
/**
* The message displayed if an invalid preset or an invalid filter is specified
*/
INVALID_PRESET_OR_FILTER,
/**
* The message displayed when showing which materials are included in a preset
*/
PRESET_MATERIALS,
/**
* The text to display when describing less than 10 seconds remaining
*/
INTERVAL_LESS_THAN_10_SECONDS,
/**
* The text to display when describing less than 30 seconds remaining
*/
INTERVAL_LESS_THAN_30_SECONDS,
/**
* The text to display when describing less than 1 minute remaining
*/
INTERVAL_LESS_THAN_1_MINUTE,
/**
* The text to display when describing less than 5 minutes remaining
*/
INTERVAL_LESS_THAN_5_MINUTES,
/**
* The text to display when describing more than 5 minutes remaining
*/
INTERVAL_MORE_THAN_5_MINUTES,
/**
* The marker used for displaying that a given setting has been overridden for the selected NPC
*/
SETTING_OVERRIDDEN_MARKER;
/**
* Gets the message to display when displaying the raw value of messages
*
* @param rawValue <p>The raw value to display</p>
* @return <p>The message to display</p>
*/
public static String getRawValueMessage(String rawValue) {
return StringFormatter.replacePlaceholder(BlacksmithPlugin.getTranslator().getTranslatedMessage(
BlacksmithTranslatableMessage.RAW_VALUE), "{rawValue}", rawValue);
}
/**
* Gets the message to display when a value has been changed
*
* @param setting <p>The setting whose value has been changed</p>
* @param newValue <p>The new value of the setting</p>
* @return <p>The string to display to a user</p>
*/
public static String getValueChangedMessage(String setting, String newValue) {
return StringFormatter.replacePlaceholders(BlacksmithPlugin.getTranslator().getTranslatedMessage(
BlacksmithTranslatableMessage.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 setting <p>The setting whose value has been changed</p>
* @param itemType <p>The type of item changed ("material" or "enchantment")</p>
* @param item <p>The item the setting was changed for (a material or an enchantment name)</p>
* @param newValue <p>The new value of the setting</p>
* @return <p>The string to display to a user</p>
*/
public static String getItemValueChangedMessage(String setting, ItemType itemType, String item, String newValue) {
return StringFormatter.replacePlaceholders(BlacksmithPlugin.getTranslator().getTranslatedMessage(
BlacksmithTranslatableMessage.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 setting <p>The setting whose value is shown</p>
* @param currentValue <p>The current value of the setting</p>
* @return <p>The string to display to a user</p>
*/
public static String getCurrentValueMessage(String setting, String currentValue) {
return StringFormatter.replacePlaceholders(BlacksmithPlugin.getTranslator().getTranslatedMessage(
BlacksmithTranslatableMessage.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 setting <p>The setting whose value is shown</p>
* @param itemType <p>The type of item shown ("material" or "enchantment")</p>
* @param item <p>The item the setting is shown for (a material or an enchantment name)</p>
* @param currentValue <p>The current value of the setting</p>
* @return <p>The string to display to a user</p>
*/
public static String getItemCurrentValueMessage(String setting, ItemType itemType, String item, String currentValue) {
return StringFormatter.replacePlaceholders(BlacksmithPlugin.getTranslator().getTranslatedMessage(
BlacksmithTranslatableMessage.CURRENT_VALUE_FOR_ITEM),
new String[]{"{setting}", "{itemType}", "{item}", "{currentValue}"},
new String[]{setting, itemType.getItemTypeName(), item, currentValue});
}
@Override
public TranslatableMessage[] getAllMessages() {
return BlacksmithTranslatableMessage.values();
}
}