diff --git a/.idea/copyright/viabackwards_gpl.xml b/.idea/copyright/viabackwards_gpl.xml
index bf99558e..8ac66561 100644
--- a/.idea/copyright/viabackwards_gpl.xml
+++ b/.idea/copyright/viabackwards_gpl.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/MappedItem.java b/common/src/main/java/com/viaversion/viabackwards/api/data/MappedItem.java
index 0460f341..04d0176d 100644
--- a/common/src/main/java/com/viaversion/viabackwards/api/data/MappedItem.java
+++ b/common/src/main/java/com/viaversion/viabackwards/api/data/MappedItem.java
@@ -17,7 +17,7 @@
*/
package com.viaversion.viabackwards.api.data;
-import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
+import com.viaversion.viaversion.util.ComponentUtil;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MappedItem {
@@ -32,7 +32,7 @@ public class MappedItem {
public MappedItem(final int id, final String name, @Nullable final Integer customModelData) {
this.id = id;
- this.jsonName = ChatRewriter.legacyTextToJsonString("§f" + name, true);
+ this.jsonName = ComponentUtil.legacyToJsonString("§f" + name, true);
this.customModelData = customModelData;
}
diff --git a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityData.java b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityData.java
index 58296637..1d2666b7 100644
--- a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityData.java
+++ b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityData.java
@@ -18,11 +18,10 @@
package com.viaversion.viabackwards.api.entities.storage;
-import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
-import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
+import com.viaversion.viaversion.util.ComponentUtil;
import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -87,7 +86,7 @@ public class EntityData {
}
if (componentType == ComponentType.JSON) {
- return ChatRewriter.legacyTextToJson(name);
+ return ComponentUtil.legacyToJson(name);
} else if (componentType == ComponentType.TAG) {
return new StringTag(name);
}
diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java
index c11087a5..3f57fd70 100644
--- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java
+++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java
@@ -24,7 +24,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
-import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
+import com.viaversion.viaversion.util.ComponentUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -103,7 +103,7 @@ public class EnchantmentRewriter {
int level = ((NumberTag) enchantmentEntry.get("lvl")).asInt();
String loreValue = remappedName + " " + getRomanNumber(level);
if (jsonFormat) {
- loreValue = ChatRewriter.legacyTextToJsonString(loreValue);
+ loreValue = ComponentUtil.legacyToJsonString(loreValue);
}
loreToAdd.add(new StringTag(loreValue));
diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java
index a995f8b3..5919280c 100644
--- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java
+++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java
@@ -41,7 +41,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
-import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
+import com.viaversion.viaversion.util.ComponentUtil;
import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -278,7 +278,7 @@ public abstract class LegacyBlockItemRewriter TO_NEW_FLOAT = new ValueTransformer(Type.FLOAT) {
@@ -53,8 +52,8 @@ public class PlayerPackets1_11 {
wrapper.clearPacket();
wrapper.setPacketType(ClientboundPackets1_9_3.CHAT_MESSAGE);
- // https://bugs.mojang.com/browse/MC-119145to
- String legacy = LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(message.toString()));
+ // https://bugs.mojang.com/browse/MC-119145
+ String legacy = ComponentUtil.jsonToLegacy(message);
message = new JsonObject();
message.getAsJsonObject().addProperty("text", legacy);
diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java
index e3fff6f7..7ac0ce0b 100644
--- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java
+++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java
@@ -39,15 +39,13 @@ import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.libs.gson.JsonParser;
-import com.viaversion.viaversion.libs.kyori.adventure.text.Component;
-import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
-import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
+import com.viaversion.viaversion.util.ComponentUtil;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Protocol1_12_2To1_13 extends BackwardsProtocol {
@@ -167,14 +165,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
@@ -115,7 +115,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
@@ -78,33 +74,8 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter {
@@ -160,7 +156,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocolget(key).asByte() == 1);
- }
- }
- componentBuilder.style(styleBuilder.build());
- }
-
- // Add the replacements
- final ListTag parameters = chatType.get("parameters");
- if (parameters != null) {
- final List arguments = new ArrayList<>();
- for (final Tag element : parameters) {
- JsonElement argument = null;
- switch ((String) element.getValue()) {
- case "sender":
- argument = senderName;
- break;
- case "content":
- argument = message;
- break;
- case "target":
- Preconditions.checkNotNull(targetName, "Target name is null");
- argument = targetName;
- break;
- default:
- ViaBackwards.getPlatform().getLogger().warning("Unknown parameter for chat decoration: " + element.getValue());
- }
- if (argument != null) {
- arguments.add(GsonComponentSerializer.gson().deserializeFromTree(argument));
- }
- }
- componentBuilder.args(arguments);
- }
-
- return GsonComponentSerializer.gson().serializeToTree(componentBuilder.build());
+ return Protocol1_19_1To1_19.translatabaleComponentFromTag(chatType, senderName, targetName, message);
}
}
diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java
index cefe9cf7..205d5743 100644
--- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java
+++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java
@@ -47,10 +47,10 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundConfigurationPackets1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ServerboundPackets1_20_3;
-import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.util.ComponentConverter;
import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
+import com.viaversion.viaversion.util.ComponentUtil;
import java.util.BitSet;
import java.util.UUID;
@@ -368,13 +368,13 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol {
@@ -99,10 +99,10 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter {
final MetaType type = meta.metaType();
if (type == Types1_20_3.META_TYPES.componentType) {
- meta.setTypeAndValue(Types1_20_2.META_TYPES.componentType, ComponentConverter.tagComponentToJson(meta.value()));
+ meta.setTypeAndValue(Types1_20_2.META_TYPES.componentType, ComponentUtil.tagToJson(meta.value()));
return;
} else if (type == Types1_20_3.META_TYPES.optionalComponentType) {
- meta.setTypeAndValue(Types1_20_2.META_TYPES.optionalComponentType, ComponentConverter.tagComponentToJson(meta.value()));
+ meta.setTypeAndValue(Types1_20_2.META_TYPES.optionalComponentType, ComponentUtil.tagToJson(meta.value()));
return;
} else if (type == Types1_20_3.META_TYPES.particleType) {
final Particle particle = (Particle) meta.getValue();