From 765efe8a33b6939d750af847ce9f6944e530940b Mon Sep 17 00:00:00 2001 From: ForceUpdate1 Date: Tue, 21 Jul 2020 22:01:55 +0200 Subject: [PATCH] Fix anvil item rename (#992) * fix anvil item rename * fix anvil item rename --- .../inventory/AnvilInventoryTranslator.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java index d0d3db882..c696479aa 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java @@ -32,6 +32,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenam import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.nukkitx.nbt.NbtMap; import com.nukkitx.protocol.bedrock.data.inventory.*; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater; @@ -106,7 +109,9 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { String rename; NbtMap tag = itemName.getTag(); if (tag != null) { - rename = tag.getCompound("display").getString("Name"); + String name = tag.getCompound("display").getString("Name"); + Component component = GsonComponentSerializer.gson().deserialize(name); + rename = LegacyComponentSerializer.legacy().serialize(component); } else { rename = ""; } @@ -138,8 +143,8 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { CompoundTag displayTag = tag.get("display"); if (displayTag != null && displayTag.contains("Name")) { String itemName = displayTag.get("Name").getValue().toString(); - TextMessage message = (TextMessage) MessageSerializer.fromString(itemName); - rename = message.getText(); + Component component = GsonComponentSerializer.gson().deserialize(itemName); + rename = LegacyComponentSerializer.legacy().serialize(component); } else { rename = ""; }