Skip to content

Commit

Permalink
Fix anvil item rename (GeyserMC#992)
Browse files Browse the repository at this point in the history
* fix anvil item rename

* fix anvil item rename
  • Loading branch information
Foorcee authored Jul 21, 2020
1 parent 30c007d commit 765efe8
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
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;
Expand Down Expand Up @@ -106,7 +109,9 @@ public void translateActions(GeyserSession session, Inventory inventory, List<In
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 = "";
}
Expand Down Expand Up @@ -138,8 +143,8 @@ public void updateSlot(GeyserSession session, Inventory inventory, int slot) {
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 = "";
}
Expand Down

0 comments on commit 765efe8

Please sign in to comment.