From 41af775cc6f3a15de27dee2f804b64156f97807e Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 26 Jul 2018 17:31:53 -0400 Subject: [PATCH] Fix some assorted stuff. --- .../proxy/connection/backend/PlaySessionHandler.java | 7 +++++++ .../proxy/connection/backend/ServerConnection.java | 3 ++- .../proxy/connection/client/PlaySessionHandler.java | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/velocitypowered/proxy/connection/backend/PlaySessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/backend/PlaySessionHandler.java index 73839d85f..92a8a56b4 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/backend/PlaySessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/backend/PlaySessionHandler.java @@ -5,6 +5,7 @@ import com.velocitypowered.proxy.protocol.packets.Disconnect; import com.velocitypowered.proxy.protocol.packets.JoinGame; import com.velocitypowered.proxy.protocol.packets.Ping; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; +import com.velocitypowered.proxy.protocol.packets.Respawn; import io.netty.buffer.ByteBuf; import net.kyori.text.TextComponent; import net.kyori.text.format.TextColor; @@ -36,6 +37,12 @@ public class PlaySessionHandler implements MinecraftSessionHandler { com.velocitypowered.proxy.connection.client.PlaySessionHandler playerHandler = (com.velocitypowered.proxy.connection.client.PlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler(); playerHandler.handleBackendJoinGame((JoinGame) packet); + } else if (packet instanceof Respawn) { + // Record the dimension switch, and then forward the packet on. + com.velocitypowered.proxy.connection.client.PlaySessionHandler playerHandler = + (com.velocitypowered.proxy.connection.client.PlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler(); + playerHandler.setCurrentDimension(((Respawn) packet).getDimension()); + connection.getProxyPlayer().getConnection().write(packet); } else { // Just forward the packet on. We don't have anything to handle at this time. connection.getProxyPlayer().getConnection().write(packet); diff --git a/src/main/java/com/velocitypowered/proxy/connection/backend/ServerConnection.java b/src/main/java/com/velocitypowered/proxy/connection/backend/ServerConnection.java index 0bea9ca94..e754416dd 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/backend/ServerConnection.java +++ b/src/main/java/com/velocitypowered/proxy/connection/backend/ServerConnection.java @@ -60,7 +60,8 @@ public class ServerConnection { // Velocity doesn't yet support online-mode, unfortunately. That will come soon. return serverInfo.getAddress().getHostString() + "\0" + proxyPlayer.getRemoteAddress().getHostString() + "\0" + - UuidUtils.toUndashed(proxyPlayer.getUniqueId()); + UuidUtils.toUndashed(proxyPlayer.getUniqueId()) + "\0" + + "[]"; } private void startHandshake() { diff --git a/src/main/java/com/velocitypowered/proxy/connection/client/PlaySessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/client/PlaySessionHandler.java index 0dfb46d1e..69c12a9e1 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/client/PlaySessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/client/PlaySessionHandler.java @@ -47,7 +47,7 @@ public class PlaySessionHandler implements MinecraftSessionHandler { if (packet instanceof Ping) { Ping ping = (Ping) packet; if (ping.getRandomId() != lastPing) { -// throw new IllegalStateException("Client sent invalid ping; expected " + lastPing + ", got " + ping.getRandomId()); + throw new IllegalStateException("Client sent invalid ping; expected " + lastPing + ", got " + ping.getRandomId()); } // Do not forward the packet to the player's server, because we handle pings for all servers already. @@ -102,4 +102,8 @@ public class PlaySessionHandler implements MinecraftSessionHandler { currentDimension = joinGame.getDimension(); } } + + public void setCurrentDimension(int currentDimension) { + this.currentDimension = currentDimension; + } }