Actually handle that

This commit is contained in:
Andrew Steinborn
2018-07-29 22:31:41 -04:00
parent 64ff0683c9
commit 201c484247
3 changed files with 14 additions and 2 deletions

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -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());
}