Skip to content

Commit

Permalink
Add getMessageString method
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Aug 4, 2024
1 parent 66cc1d5 commit 6a700ae
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Message, String> 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) {
Expand Down

0 comments on commit 6a700ae

Please sign in to comment.