From 9e2eda672dd576e612a4a529842e0bb933036e53 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 Feb 2013 19:01:18 +1100 Subject: [PATCH] Cache the client status packet. --- proxy/src/main/java/net/md_5/bungee/ServerConnection.java | 2 +- proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java | 2 +- .../main/java/net/md_5/bungee/packet/PacketCDClientStatus.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java index a61231bb..b29a5c0c 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -49,7 +49,7 @@ public class ServerConnection extends GenericConnection implements Server PacketStream stream = new PacketStream( socket.getInputStream(), socket.getOutputStream() ); stream.write( handshake ); - stream.write( new PacketCDClientStatus( (byte) 0 ) ); + stream.write( PacketCDClientStatus.CLIENT_LOGIN ); stream.readPacket(); byte[] loginResponse = stream.readPacket(); diff --git a/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java b/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java index b8ccdead..3051b31d 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java @@ -64,7 +64,7 @@ public abstract class DefinedPacket implements DataInput, DataOutput */ public byte[] getPacket() { - return packet == null ? out.toByteArray() : packet; + return packet == null ? packet = out.toByteArray() : packet; } @Override diff --git a/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java b/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java index 7f854bea..08bdc103 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java @@ -8,6 +8,8 @@ import lombok.ToString; public class PacketCDClientStatus extends DefinedPacket { + public static PacketCDClientStatus CLIENT_LOGIN = new PacketCDClientStatus( (byte) 0 ); + /** * Sent from the client to the server upon respawn, *