diff --git a/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java b/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java index 4918271..b06e767 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java +++ b/src/main/java/com/github/creeper123123321/viafabric/platform/VRPlatform.java @@ -57,9 +57,10 @@ import us.myles.ViaVersion.api.platform.TaskId; import us.myles.ViaVersion.api.platform.ViaConnectionManager; import us.myles.ViaVersion.api.platform.ViaPlatform; import us.myles.ViaVersion.dump.PluginInfo; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; import us.myles.ViaVersion.sponge.VersionInfo; import us.myles.ViaVersion.util.GsonUtil; +import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent; +import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer; import us.myles.viaversion.libs.gson.JsonObject; import java.io.File; @@ -231,7 +232,9 @@ public class VRPlatform implements ViaPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendMessage(Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(s)), false); + player.sendMessage(Text.Serializer.fromJson( + legacyToJson(s) + ), false); }); } @@ -241,7 +244,7 @@ public class VRPlatform implements ViaPlatform { if (handler != null) { try { handler.onGameMessage(new GameMessageS2CPacket( - Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(s)), MessageType.SYSTEM, Util.NIL_UUID + Text.Serializer.fromJson(legacyToJson(s)), MessageType.SYSTEM, Util.NIL_UUID )); } catch (OffThreadException ignored) { } @@ -264,7 +267,7 @@ public class VRPlatform implements ViaPlatform { if (handler != null) { try { handler.onDisconnect(new DisconnectS2CPacket( - Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(msg)) + Text.Serializer.fromJson(legacyToJson(msg)) )); } catch (OffThreadException ignored) { } @@ -279,7 +282,7 @@ public class VRPlatform implements ViaPlatform { Supplier kickTask = () -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return false; - player.networkHandler.disconnect(Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(s))); + player.networkHandler.disconnect(Text.Serializer.fromJson(legacyToJson(s))); return true; }; if (server.isOnThread()) { @@ -350,4 +353,8 @@ public class VRPlatform implements ViaPlatform { public ViaConnectionManager getConnectionManager() { return connectionManager; } + + private String legacyToJson(String legacy) { + return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy)); + } }