diff --git a/src/main/java/net/knarcraft/knarlib/formatting/StringReplacer.java b/src/main/java/net/knarcraft/knarlib/formatting/StringReplacer.java index c703d6e..c0f7869 100644 --- a/src/main/java/net/knarcraft/knarlib/formatting/StringReplacer.java +++ b/src/main/java/net/knarcraft/knarlib/formatting/StringReplacer.java @@ -52,6 +52,43 @@ public final class StringReplacer { this.replacements.put(placeholder, value); } + /** + * Adds a new string replacement + * + * @param stringFormatter

The string formatter to use for translation

+ * @param placeholder

The placeholder to replace

+ * @param value

The replacement value

+ */ + 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

The string formatter to use for translation

+ * @param placeholder

The placeholder to replace

+ * @param value

The replacement value

+ */ + 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

The string formatter to use for translation

+ * @param placeholder

The placeholder to replace

+ * @param value

The replacement value

+ */ + public void add(@NotNull StringFormatter stringFormatter, @NotNull TranslatableMessage placeholder, + @NotNull String value) { + this.replacements.put(stringFormatter.getUnFormattedMessage(placeholder), value); + } + /** * Removes a string replacement *