1919import net .raphimc .netminecraft .constants .MCPackets ;
2020import net .raphimc .netminecraft .netty .connection .NetClient ;
2121import net .raphimc .netminecraft .packet .PacketTypes ;
22+ import net .raphimc .vialegacy .api .LegacyProtocolVersion ;
2223import net .raphimc .vialegacy .protocols .release .protocol1_6_1to1_5_2 .ClientboundPackets1_5_2 ;
2324import net .raphimc .vialegacy .protocols .release .protocol1_6_1to1_5_2 .ServerboundPackets1_5_2 ;
2425import net .raphimc .vialegacy .protocols .release .protocol1_7_2_5to1_6_4 .types .Types1_6_4 ;
@@ -69,7 +70,7 @@ public void encode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
6970 return ;
7071 }
7172 if (version .isNewerThan (VersionEnum .r1_6_4 )) {
72- if (in .readableBytes () = = 2 && in .getUnsignedByte (0 ) == 0xFE && in .getUnsignedByte (1 ) == 0x01 ) {
73+ if (in .readableBytes () > = 2 && in .getUnsignedByte (0 ) == 0xFE && in .getUnsignedByte (1 ) == 0x01 ) {
7374 handshakeState = -1 ;
7475 out .add (new TextWebSocketFrame ("Accept: MOTD" ));
7576 return ;
@@ -145,7 +146,7 @@ public void encode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
145146 }
146147
147148 public void encodeOld (ChannelHandlerContext ctx , ByteBuf in , List <Object > out ) {
148- if (in .readableBytes () = = 2 && in .getUnsignedByte (0 ) == 0xFE && in .getUnsignedByte (1 ) == 0x01 ) {
149+ if (in .readableBytes () > = 2 && in .getUnsignedByte (0 ) == 0xFE && in .getUnsignedByte (1 ) == 0x01 ) {
149150 handshakeState = -1 ;
150151 out .add (new TextWebSocketFrame ("Accept: MOTD" ));
151152 return ;
@@ -249,8 +250,8 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
249250 if (handshakeState == -1 ) {
250251 ByteBuf bb = ctx .alloc ().buffer ();
251252 bb .writeByte ((byte ) 0xFF );
252- StringBuilder sb = new StringBuilder ("§1 \0 " );
253- sb .append (version .getVersion ()).append ("\0 " );
253+ StringBuilder sb = new StringBuilder ("\u00A7 1 \0 " );
254+ sb .append (LegacyProtocolVersion . getRealProtocolVersion ( version .getVersion () )).append ("\0 " );
254255 sb .append (version .getName ()).append ("\0 " );
255256 sb .append (motdSb ).append ("\0 " );
256257 sb .append (online ).append ("\0 " );
@@ -275,7 +276,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
275276 JsonObject resp = new JsonObject ();
276277 JsonObject versionObj = new JsonObject ();
277278 versionObj .addProperty ("name" , version .getName ());
278- versionObj .addProperty ("protocol" , version .getVersion ());
279+ versionObj .addProperty ("protocol" , LegacyProtocolVersion . getRealProtocolVersion ( version .getVersion () ));
279280 resp .add ("version" , versionObj );
280281 JsonObject playersObj = new JsonObject ();
281282 playersObj .addProperty ("max" , max );
@@ -326,7 +327,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
326327 JsonObject resp = new JsonObject ();
327328 JsonObject versionObj = new JsonObject ();
328329 versionObj .addProperty ("name" , version .getName ());
329- versionObj .addProperty ("protocol" , version .getVersion ());
330+ versionObj .addProperty ("protocol" , LegacyProtocolVersion . getRealProtocolVersion ( version .getVersion () ));
330331 resp .add ("version" , versionObj );
331332 JsonObject playersObj = new JsonObject ();
332333 playersObj .addProperty ("max" , serverInfo .max );
0 commit comments