Makes edit commands display the default value if no value is provided

This commit is contained in:
2024-05-07 13:54:45 +02:00
parent cb477cafb5
commit 75744ccdd0
4 changed files with 71 additions and 28 deletions

View File

@@ -30,6 +30,11 @@ public enum BlacksmithTranslatableMessage implements TranslatableMessage {
*/
CURRENT_VALUE,
/**
* The message displayed when showing the default value of a configuration option
*/
DEFAULT_VALUE,
/**
* The message displayed when showing the current value of a configuration option for one material or enchantment
*/
@@ -186,6 +191,20 @@ public enum BlacksmithTranslatableMessage implements TranslatableMessage {
return stringReplacer.replace();
}
/**
* Gets the message to display when displaying a setting's default value
*
* @param setting <p>The setting whose value is shown</p>
* @param defaultValue <p>The default value of the setting</p>
* @return <p>The string to display to a user</p>
*/
@NotNull
public static String getDefaultValueMessage(@NotNull String setting, @NotNull String defaultValue) {
return BlacksmithPlugin.getStringFormatter().replacePlaceholders(BlacksmithTranslatableMessage.DEFAULT_VALUE,
List.of("{setting}", "{defaultValue}"),
List.of(setting, defaultValue));
}
/**
* Gets the message to display when displaying a setting's current value
*