Fix transltable component rendering in plain text

This commit is contained in:
Vankka 2024-06-21 15:01:56 +03:00
parent 73bd92fc86
commit f8898be428
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB

View File

@ -32,7 +32,6 @@ import dev.vankka.mcdiscordreserializer.minecraft.MinecraftSerializer;
import dev.vankka.mcdiscordreserializer.minecraft.MinecraftSerializerOptions;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.TranslationArgument;
import net.kyori.adventure.text.flattener.ComponentFlattener;
import net.kyori.adventure.text.serializer.ansi.ANSIComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@ -93,7 +92,8 @@ public class ComponentFactory implements MinecraftComponentFactory {
return translation.translate(
component.arguments()
.stream()
.map(TranslationArgument::value)
// Prevent infinite loop here by using the default PlainTextSerializer
.map(argument -> PlainTextComponentSerializer.plainText().serialize(argument.asComponent()))
.toArray(Object[]::new)
);
}