Skip to content

Commit

Permalink
Update Adventure-Legacy dependency (GeyserMC#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy authored Jul 22, 2020
1 parent b211b9d commit ad9184a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
package org.geysermc.connector.network.translators.inventory;

import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.github.steveice10.mc.protocol.data.message.TextMessage;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.NbtMap;
Expand Down Expand Up @@ -111,7 +109,7 @@ public void translateActions(GeyserSession session, Inventory inventory, List<In
if (tag != null) {
String name = tag.getCompound("display").getString("Name");
Component component = GsonComponentSerializer.gson().deserialize(name);
rename = LegacyComponentSerializer.legacy().serialize(component);
rename = LegacyComponentSerializer.legacySection().serialize(component);
} else {
rename = "";
}
Expand Down Expand Up @@ -144,7 +142,7 @@ public void updateSlot(GeyserSession session, Inventory inventory, int slot) {
if (displayTag != null && displayTag.contains("Name")) {
String itemName = displayTag.get("Name").getValue().toString();
Component component = GsonComponentSerializer.gson().deserialize(itemName);
rename = LegacyComponentSerializer.legacy().serialize(component);
rename = LegacyComponentSerializer.legacySection().serialize(component);
} else {
rename = "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static ItemData translateToBedrock(GeyserSession session, ItemStack stack

// If its not a message convert it
if (!MessageUtils.isMessage(name)) {
TextComponent component = LegacyComponentSerializer.legacy().deserialize(name);
TextComponent component = LegacyComponentSerializer.legacySection().deserialize(name);
name = GsonComponentSerializer.gson().serialize(component);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ private String toBedrockMessage(StringTag tag) {
String message = tag.getValue();
if (message == null) return null;
TextComponent component = (TextComponent) MessageUtils.phraseJavaMessage(message);
String legacy = LegacyComponentSerializer.legacy().serialize(component);
if (hasFormatting(LegacyComponentSerializer.legacy().deserialize(legacy))) {
String legacy = LegacyComponentSerializer.legacySection().serialize(component);
if (hasFormatting(LegacyComponentSerializer.legacySection().deserialize(legacy))) {
return "§r" + legacy;
}
return legacy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ public static String getBedrockMessageLenient(String message) {

public static String getBedrockMessage(String message) {
Component component = phraseJavaMessage(message);
return LegacyComponentSerializer.legacy().serialize(component);
return LegacyComponentSerializer.legacySection().serialize(component);
}

public static Component phraseJavaMessage(String message) {
return GsonComponentSerializer.gson().deserialize(message);
}

public static String getJavaMessage(String message) {
Component component = LegacyComponentSerializer.legacy().deserialize(message);
Component component = LegacyComponentSerializer.legacySection().deserialize(message);
return GsonComponentSerializer.gson().serialize(component);
}

Expand Down

0 comments on commit ad9184a

Please sign in to comment.