|
25 | 25 |
|
26 | 26 | package org.geysermc.geyser.translator.text;
|
27 | 27 |
|
28 |
| -import java.util.ArrayList; |
29 |
| -import java.util.List; |
30 | 28 | import net.kyori.adventure.text.Component;
|
31 | 29 | import net.kyori.adventure.text.JoinConfiguration;
|
32 | 30 | import net.kyori.adventure.text.ScoreComponent;
|
|
57 | 55 | import org.geysermc.mcprotocollib.protocol.data.game.chat.ChatType;
|
58 | 56 | import org.geysermc.mcprotocollib.protocol.data.game.chat.ChatTypeDecoration;
|
59 | 57 |
|
| 58 | +import java.util.ArrayList; |
| 59 | +import java.util.List; |
| 60 | + |
60 | 61 | public class MessageTranslator {
|
61 | 62 | // These are used for handling the translations of the messages
|
62 | 63 | // Custom instead of TranslatableComponentRenderer#usingTranslationSource so we don't need to worry about finding a Locale class
|
@@ -202,13 +203,6 @@ private static String convertMessage(Component message, String locale, boolean a
|
202 | 203 | }
|
203 | 204 | }
|
204 | 205 |
|
205 |
| - /** |
206 |
| - * Convenience method for locale getting. |
207 |
| - */ |
208 |
| - public static String convertJsonMessage(GeyserSession session, String message) { |
209 |
| - return convertJsonMessage(message, session.locale()); |
210 |
| - } |
211 |
| - |
212 | 206 | public static String convertJsonMessage(String message, String locale) {
|
213 | 207 | return convertMessage(GSON_SERIALIZER.deserialize(message), locale);
|
214 | 208 | }
|
@@ -448,6 +442,15 @@ public static Component componentFromNbtTag(Object nbtTag) {
|
448 | 442 | return componentFromNbtTag(nbtTag, Style.empty());
|
449 | 443 | }
|
450 | 444 |
|
| 445 | + public static List<String> signTextFromNbtTag(GeyserSession session, List<?> nbtTag) { |
| 446 | + var components = componentsFromNbtList(nbtTag, Style.empty()); |
| 447 | + List<String> messages = new ArrayList<>(); |
| 448 | + for (Component component : components) { |
| 449 | + messages.add(convertMessageRaw(component, session.locale())); |
| 450 | + } |
| 451 | + return messages; |
| 452 | + } |
| 453 | + |
451 | 454 | private static Component componentFromNbtTag(Object nbtTag, Style style) {
|
452 | 455 | if (nbtTag instanceof String literal) {
|
453 | 456 | return Component.text(literal).style(style);
|
|
0 commit comments