From c9840a1bc9d951a07282b6d6abd22912b3e1e6c5 Mon Sep 17 00:00:00 2001 From: Slqmy <90862990+Slqmy@users.noreply.github.com> Date: Thu, 8 Aug 2024 00:15:37 +0100 Subject: [PATCH] Add `sendMessage` methods --- .../language/LanguageManager.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) 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 20c1a661..c1290a11 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 @@ -272,6 +272,54 @@ public Component getMessage(Message message, PlayerProfile playerProfile, Object return getMessage(message, playerProfile, true, arguments); } + public void sendMessage(Message message, CommandSender commandSender, boolean fallbackOnDefaultLanguage, Component... arguments) { + commandSender.sendMessage(getMessage(message, getLanguage(commandSender), fallbackOnDefaultLanguage, arguments)); + } + + public void sendMessage(Message message, CommandSender commandSender, Component... arguments) { + commandSender.sendMessage(getMessage(message, commandSender, true, arguments)); + } + + public void sendMessage(Message message, CommandSender commandSender, boolean fallbackOnDefaultLanguage, Object... arguments) { + commandSender.sendMessage(getMessage(message, commandSender, fallbackOnDefaultLanguage, toComponents(arguments))); + } + + public void sendMessage(Message message, CommandSender commandSender, Object... arguments) { + commandSender.sendMessage(getMessage(message, commandSender, true, arguments)); + } + + public void sendMessage(Message message, UUID uuid, boolean fallbackOnDefaultLanguage, Component... arguments) { + Bukkit.getPlayer(uuid).sendMessage(getMessage(message, getLanguage(uuid), fallbackOnDefaultLanguage, arguments)); + } + + public void sendMessage(Message message, UUID uuid, Component... arguments) { + Bukkit.getPlayer(uuid).sendMessage(getMessage(message, uuid, true, arguments)); + } + + public void sendMessage(Message message, UUID uuid, boolean fallbackOnDefaultLanguage, Object... arguments) { + Bukkit.getPlayer(uuid).sendMessage(getMessage(message, uuid, fallbackOnDefaultLanguage, toComponents(arguments))); + } + + public void sendMessage(Message message, UUID uuid, Object... arguments) { + Bukkit.getPlayer(uuid).sendMessage(getMessage(message, uuid, true, arguments)); + } + + public void sendMessage(Message message, PlayerProfile playerProfile, boolean fallbackOnDefaultLanguage, Component... arguments) { + Bukkit.getPlayer(playerProfile.getUuid()).sendMessage(getMessage(message, getLanguage(playerProfile), fallbackOnDefaultLanguage, arguments)); + } + + public void sendMessage(Message message, PlayerProfile playerProfile, Component... arguments) { + Bukkit.getPlayer(playerProfile.getUuid()).sendMessage(getMessage(message, playerProfile, true, arguments)); + } + + public void sendMessage(Message message, PlayerProfile playerProfile, boolean fallbackOnDefaultLanguage, Object... arguments) { + Bukkit.getPlayer(playerProfile.getUuid()).sendMessage(getMessage(message, playerProfile, fallbackOnDefaultLanguage, toComponents(arguments))); + } + + public void sendMessage(Message message, PlayerProfile playerProfile, Object... arguments) { + Bukkit.getPlayer(playerProfile.getUuid()).sendMessage(getMessage(message, playerProfile, true, arguments)); + } + public Component[] toComponents(Object ...objects) { return Stream.of(objects).map((object) -> toComponent(object)).toArray(Component[]::new); }