From 6a700aea7e047ce9133ed3edb7e7479c6977e061 Mon Sep 17 00:00:00 2001 From: Slqmy <90862990+Slqmy@users.noreply.github.com> Date: Sun, 4 Aug 2024 16:59:11 +0100 Subject: [PATCH] Add `getMessageString` method --- .../language/LanguageManager.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/slqmy/template_paper_plugin/language/LanguageManager.java b/src/main/java/net/slqmy/template_paper_plugin/language/LanguageManager.java index 0ea9ce8e..9af52879 100644 --- a/src/main/java/net/slqmy/template_paper_plugin/language/LanguageManager.java +++ b/src/main/java/net/slqmy/template_paper_plugin/language/LanguageManager.java @@ -119,15 +119,23 @@ public void setLanguage(Player player, String language) { setLanguage(player.getUniqueId(), language); } - public Component getMessage(Message message, String language, boolean fallbackOnDefaultLanguage, Object... arguments) { + public String getMessageString(Message message, String language, boolean fallbackOnDefaultLanguage, Object... arguments) { Map languageMessageMap = languages.get(language); String miniMessageString = languageMessageMap.get(message); if (miniMessageString == null) { - return fallbackOnDefaultLanguage ? getMessage(message, defaultLanguage, false, arguments) : null; + return fallbackOnDefaultLanguage ? getMessageString(message, defaultLanguage, false, arguments) : null; } - return miniMessage.deserialize(String.format(miniMessageString, arguments)); + return String.format(miniMessageString, arguments); + } + + public String getMessageString(Message message, String language, Object... arguments) { + return getMessageString(message, language, true, arguments); + } + + public Component getMessage(Message message, String language, boolean fallbackOnDefaultLanguage, Object... arguments) { + return miniMessage.deserialize(getMessageString(message, language, fallbackOnDefaultLanguage, arguments)); } public Component getMessage(Message message, String language, Object... arguments) {