diff --git a/src/main/java/com/viaversion/fabric/common/util/RemappingUtil.java b/src/main/java/com/viaversion/fabric/common/util/RemappingUtil.java index 6b9c8da..12d574d 100644 --- a/src/main/java/com/viaversion/fabric/common/util/RemappingUtil.java +++ b/src/main/java/com/viaversion/fabric/common/util/RemappingUtil.java @@ -1,8 +1,5 @@ package com.viaversion.fabric.common.util; -import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; - public class RemappingUtil { public static int swordId(String id) { // https://github.com/ViaVersion/ViaVersion/blob/8de26a0ad33f5b739f5394ed80f69d14197fddc7/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java#L86 @@ -21,12 +18,4 @@ public class RemappingUtil { return 0; } - private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.builder() - .character('ยง') - .extractUrls() - .build(); - - public static String legacyToJson(String legacy) { - return GsonComponentSerializer.gson().serialize(LEGACY_SERIALIZER.deserialize(legacy)); - } } diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java index e3236b1..295ce56 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java @@ -1,7 +1,7 @@ package com.viaversion.fabric.mc114.commands; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.viaversion.api.command.ViaCommandSender; +import com.viaversion.viaversion.util.ComponentUtil; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; @@ -28,7 +28,7 @@ public class NMSCommandSender implements ViaCommandSender { } public static Text fromLegacy(String legacy) { - return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy)); } @Override diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java index cf4bb99..f9f2c34 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java @@ -1,7 +1,7 @@ package com.viaversion.fabric.mc115.commands; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.viaversion.api.command.ViaCommandSender; +import com.viaversion.viaversion.util.ComponentUtil; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; @@ -28,7 +28,7 @@ public class NMSCommandSender implements ViaCommandSender { } public static Text fromLegacy(String legacy) { - return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy)); } @Override diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java index 1b34015..fadaaa1 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java @@ -1,7 +1,7 @@ package com.viaversion.fabric.mc116.commands; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.viaversion.api.command.ViaCommandSender; +import com.viaversion.viaversion.util.ComponentUtil; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; @@ -25,7 +25,7 @@ public class NMSCommandSender implements ViaCommandSender { } public static Text fromLegacy(String legacy) { - return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy)); } @Override diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java index e89d794..790d41e 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java @@ -1,6 +1,6 @@ package com.viaversion.fabric.mc117.commands; -import com.viaversion.fabric.common.util.RemappingUtil; +import com.viaversion.viaversion.util.ComponentUtil; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; @@ -26,7 +26,7 @@ public class NMSCommandSender implements ViaCommandSender { } public static MutableText fromLegacy(String legacy) { - return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy)); } @Override diff --git a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java index d69edb9..292e970 100644 --- a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java +++ b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java @@ -1,6 +1,6 @@ package com.viaversion.fabric.mc118.commands; -import com.viaversion.fabric.common.util.RemappingUtil; +import com.viaversion.viaversion.util.ComponentUtil; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; @@ -25,7 +25,7 @@ public class NMSCommandSender implements ViaCommandSender { } public static Text fromLegacy(String legacy) { - return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy)); } @Override diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java index 2961f49..3eb815d 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java @@ -1,6 +1,6 @@ package com.viaversion.fabric.mc119.commands; -import com.viaversion.fabric.common.util.RemappingUtil; +import com.viaversion.viaversion.util.ComponentUtil; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; @@ -26,7 +26,7 @@ public class NMSCommandSender implements ViaCommandSender { } public static MutableText fromLegacy(String legacy) { - return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy)); } @Override diff --git a/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/commands/NMSCommandSender.java b/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/commands/NMSCommandSender.java index 11ccf35..ea4fd65 100644 --- a/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/commands/NMSCommandSender.java +++ b/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/commands/NMSCommandSender.java @@ -1,6 +1,6 @@ package com.viaversion.fabric.mc120.commands; -import com.viaversion.fabric.common.util.RemappingUtil; +import com.viaversion.viaversion.util.ComponentUtil; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; @@ -26,7 +26,7 @@ public class NMSCommandSender implements ViaCommandSender { } public static MutableText fromLegacy(String legacy) { - return Text.Serialization.fromJson(RemappingUtil.legacyToJson(legacy)); + return Text.Serialization.fromJson(ComponentUtil.legacyToJsonString(legacy)); } @Override diff --git a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/commands/NMSCommandSender.java b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/commands/NMSCommandSender.java index 7073bb5..2845a37 100644 --- a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/commands/NMSCommandSender.java +++ b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/commands/NMSCommandSender.java @@ -1,7 +1,7 @@ package com.viaversion.fabric.mc18.commands; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.viaversion.api.command.ViaCommandSender; +import com.viaversion.viaversion.util.ComponentUtil; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; import net.minecraft.text.Text; @@ -24,7 +24,7 @@ public class NMSCommandSender implements ViaCommandSender { @Override public void sendMessage(String s) { - source.sendMessage(Text.Serializer.deserialize(RemappingUtil.legacyToJson(s))); + source.sendMessage(Text.Serializer.deserialize(ComponentUtil.legacyToJsonString(s))); } @Override diff --git a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/FabricPlatform.java b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/FabricPlatform.java index e8a6910..cc6dcc3 100644 --- a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/FabricPlatform.java +++ b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/FabricPlatform.java @@ -4,11 +4,11 @@ import com.viaversion.fabric.common.commands.UserCommandSender; import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.common.provider.AbstractFabricPlatform; import com.viaversion.fabric.common.util.FutureTaskId; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc18.ViaFabric; import com.viaversion.fabric.mc18.commands.NMSCommandSender; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.command.ViaCommandSender; +import com.viaversion.viaversion.util.ComponentUtil; import io.netty.channel.EventLoop; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; @@ -106,7 +106,7 @@ public class FabricPlatform extends AbstractFabricPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendMessage(Text.Serializer.deserialize(RemappingUtil.legacyToJson(s))); + player.sendMessage(Text.Serializer.deserialize(ComponentUtil.legacyToJsonString(s))); }); }