From 201c4842470268d541676217f078372ecb7ef046 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 29 Jul 2018 22:31:41 -0400 Subject: [PATCH] Actually handle that --- .../connection/backend/BackendPlaySessionHandler.java | 5 +++++ .../connection/client/ClientPlaySessionHandler.java | 9 ++++++++- .../proxy/connection/client/ConnectedPlayer.java | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index 1ee9006e9..db342c2ad 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -44,4 +44,9 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { public void handleUnknown(ByteBuf buf) { connection.getProxyPlayer().getConnection().write(buf.retain()); } + + @Override + public void exception(Throwable throwable) { + connection.getProxyPlayer().handleConnectionException(connection.getServerInfo(), throwable); + } } diff --git a/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 5b352aac5..ef48336d8 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -6,8 +6,11 @@ import com.velocitypowered.proxy.data.ServerInfo; import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.packets.*; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; +import com.velocitypowered.proxy.util.ThrowableUtils; import io.netty.buffer.ByteBuf; import io.netty.channel.EventLoop; +import net.kyori.text.TextComponent; +import net.kyori.text.format.TextColor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -90,7 +93,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { @Override public void exception(Throwable throwable) { - player.handleConnectionException(player.getConnectedServer().getServerInfo(), throwable); + player.close(TextComponent.builder() + .content("An exception occurred in your connection: ") + .color(TextColor.RED) + .append(TextComponent.of(ThrowableUtils.briefDescription(throwable), TextColor.WHITE)) + .build()); } public void handleBackendJoinGame(JoinGame joinGame) { diff --git a/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 3c983cfd8..f474a4383 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -81,7 +81,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation { handleConnectionException(info, TextComponent.builder() .content(userMessage + ": ") .color(TextColor.RED) - .append(TextComponent.of(error)) + .append(TextComponent.of(error, TextColor.WHITE)) .build()); }