From 2f99a17d020bc96e61231ed21c8de6427e6791e8 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 7 Oct 2021 16:16:07 +0100 Subject: [PATCH] TODO: Finish Components --- .../com/willfp/eco/proxy/v1_17_R1/ChatComponent.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/ChatComponent.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/ChatComponent.kt index ded31e6a..639fa18e 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/ChatComponent.kt +++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/ChatComponent.kt @@ -28,17 +28,14 @@ class ChatComponent : ChatComponentProxy { ) ).asComponent() as BuildableComponent<*, *> - val newComponent = modifyBaseComponent(component, player) + val newComponent = component.toBuilder().mapChildrenDeep { modifyBaseComponent(it, player) as BuildableComponent<*, *> }.asComponent() return net.minecraft.network.chat.Component.Serializer.fromJson( gsonComponentSerializer.serialize(newComponent) ) ?: obj } - private fun , B: ComponentBuilder> modifyBaseComponent(baseComponent: BuildableComponent, player: Player): Component { - val component = baseComponent.toBuilder().mapChildren { - modifyBaseComponent(it, player) as BuildableComponent - }.asComponent() + private fun , B: ComponentBuilder> modifyBaseComponent(component: BuildableComponent, player: Player): Component { val hoverEvent: HoverEvent = component.style().hoverEvent() as HoverEvent? ?: return component val showItem = hoverEvent.value() @@ -68,6 +65,7 @@ class ChatComponent : ChatComponentProxy { val newHover = hoverEvent.value(newShowItem) val style = component.style().hoverEvent(newHover) - return component.style(style) + val newComponent = component.style(style) + return newComponent } } \ No newline at end of file