Makes the string replacer more useful for translatable messages
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good

This commit is contained in:
2025-09-03 03:05:48 +02:00
parent dee068f142
commit 0a4b9d5d8a

View File

@@ -52,6 +52,43 @@ public final class StringReplacer {
this.replacements.put(placeholder, value);
}
/**
* Adds a new string replacement
*
* @param stringFormatter <p>The string formatter to use for translation</p>
* @param placeholder <p>The placeholder to replace</p>
* @param value <p>The replacement value</p>
*/
public void add(@NotNull StringFormatter stringFormatter, @NotNull TranslatableMessage placeholder,
@NotNull TranslatableMessage value) {
this.replacements.put(stringFormatter.getUnFormattedMessage(placeholder),
stringFormatter.getUnFormattedMessage(value));
}
/**
* Adds a new string replacement
*
* @param stringFormatter <p>The string formatter to use for translation</p>
* @param placeholder <p>The placeholder to replace</p>
* @param value <p>The replacement value</p>
*/
public void add(@NotNull StringFormatter stringFormatter, @NotNull String placeholder,
@NotNull TranslatableMessage value) {
this.replacements.put(placeholder, stringFormatter.getUnFormattedMessage(value));
}
/**
* Adds a new string replacement
*
* @param stringFormatter <p>The string formatter to use for translation</p>
* @param placeholder <p>The placeholder to replace</p>
* @param value <p>The replacement value</p>
*/
public void add(@NotNull StringFormatter stringFormatter, @NotNull TranslatableMessage placeholder,
@NotNull String value) {
this.replacements.put(stringFormatter.getUnFormattedMessage(placeholder), value);
}
/**
* Removes a string replacement
*