From 265e5864c9f1c5b126f3f21be388684f2289aee0 Mon Sep 17 00:00:00 2001 From: ceze88 Date: Mon, 26 Aug 2024 19:53:41 +0200 Subject: [PATCH] Add method to allow Number and Boolean types for placeholders --- .../java/com/craftaro/core/locale/Message.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/craftaro/core/locale/Message.java b/Core/src/main/java/com/craftaro/core/locale/Message.java index 8389be28..63f89ce3 100644 --- a/Core/src/main/java/com/craftaro/core/locale/Message.java +++ b/Core/src/main/java/com/craftaro/core/locale/Message.java @@ -147,7 +147,7 @@ public List getMessageLines() { * Interchangeably Supports {@code %value%} and {@code {value}} * * @param placeholder the placeholder to replace - * @param replacement the replacement object + * @param replacement the replacement String * * @return the modified Message */ @@ -158,6 +158,19 @@ public Message processPlaceholder(String placeholder, String replacement) { return this; } + /** + * Replace the provided placeholder with the provided object.
+ * Interchangeably Supports {@code %value%} and {@code {value}} + * + * @param placeholder the placeholder to replace + * @param replacement the replacement Number + * + * @return the modified Message + */ + public Message processPlaceholder(String placeholder, Number replacement) { + return processPlaceholder(placeholder, replacement == null ? "" : replacement.toString()); + } + Message setPrefix(String prefix) { this.prefix = AdventureUtils.formatComponent(prefix + " "); return this;