From 6b4e2851869989cb15126c229c151465cc27f212 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 16 Mar 2016 16:53:19 +1100 Subject: [PATCH] 1.9.1 support --- .../java/net/md_5/bungee/protocol/Protocol.java | 9 ++++++--- .../md_5/bungee/protocol/ProtocolConstants.java | 5 ++++- .../protocol/packet/EncryptionRequest.java | 4 ++-- .../protocol/packet/EncryptionResponse.java | 4 ++-- .../net/md_5/bungee/protocol/packet/Login.java | 16 ++++++++++++++-- .../net/md_5/bungee/entitymap/EntityMap.java | 1 + 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java index 23162561..8338d239 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java @@ -108,7 +108,8 @@ public enum Protocol public static final int MAX_PACKET_ID = 0xFF; public static List supportedVersions = Arrays.asList( ProtocolConstants.MINECRAFT_1_8, - ProtocolConstants.MINECRAFT_1_9 + ProtocolConstants.MINECRAFT_1_9, + ProtocolConstants.MINECRAFT_1_9_1 ); /*========================================================================*/ public final DirectionData TO_SERVER = new DirectionData( ProtocolConstants.Direction.TO_SERVER ); @@ -131,8 +132,10 @@ public enum Protocol { packetRemap.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() ); packetRemapInv.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() ); - packetRemap.put(ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() ); - packetRemapInv.put(ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() ); + packetRemap.put( ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() ); + packetRemapInv.put( ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() ); + packetRemap.put( ProtocolConstants.MINECRAFT_1_9_1, packetRemap.get( ProtocolConstants.MINECRAFT_1_9 ) ); + packetRemapInv.put( ProtocolConstants.MINECRAFT_1_9_1, packetRemapInv.get( ProtocolConstants.MINECRAFT_1_9 ) ); } public final DefinedPacket createPacket(int id, int protocol) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java index 5100d586..6f6f3e3c 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java @@ -5,11 +5,14 @@ import java.util.List; public class ProtocolConstants { + public static final int MINECRAFT_1_8 = 47; public static final int MINECRAFT_1_9 = 107; + public static final int MINECRAFT_1_9_1 = 108; public static final List SUPPORTED_VERSIONS = Arrays.asList( "1.8.x", - "1.9" + "1.9", + "1.9.1" ); public enum Direction diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java index a29524ca..031144e2 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java @@ -24,8 +24,8 @@ public class EncryptionRequest extends DefinedPacket public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { serverId = readString( buf ); - publicKey = readArray( buf ); - verifyToken = readArray( buf ); + publicKey = readArray( buf, 128 ); + verifyToken = readArray( buf, 128 ); } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java index 0110630d..06676e42 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java @@ -22,8 +22,8 @@ public class EncryptionResponse extends DefinedPacket @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - sharedSecret = readArray( buf, 256 ); - verifyToken = readArray( buf, 256 ); + sharedSecret = readArray( buf, 128 ); + verifyToken = readArray( buf, 128 ); } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java index 31df7963..2e3915ce 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java @@ -29,7 +29,13 @@ public class Login extends DefinedPacket { entityId = buf.readInt(); gameMode = buf.readUnsignedByte(); - dimension = buf.readByte(); + if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 ) + { + dimension = buf.readInt(); + } else + { + dimension = buf.readByte(); + } difficulty = buf.readUnsignedByte(); maxPlayers = buf.readUnsignedByte(); levelType = readString( buf ); @@ -44,7 +50,13 @@ public class Login extends DefinedPacket { buf.writeInt( entityId ); buf.writeByte( gameMode ); - buf.writeByte( dimension ); + if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 ) + { + buf.writeInt( dimension ); + } else + { + buf.writeByte( dimension ); + } buf.writeByte( difficulty ); buf.writeByte( maxPlayers ); writeString( levelType, buf ); diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 17f94546..321668bc 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -28,6 +28,7 @@ public abstract class EntityMap case ProtocolConstants.MINECRAFT_1_8: return EntityMap_1_8.INSTANCE; case ProtocolConstants.MINECRAFT_1_9: + case ProtocolConstants.MINECRAFT_1_9_1: return EntityMap_1_9.INSTANCE; } throw new RuntimeException( "Version " + version + " has no entity map" );