From 23ce4d1b96edfbd47c7ad400b233fefb5a55dd64 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 16 Mar 2016 16:49:50 +1100 Subject: [PATCH] Add 1.9.1 support. --- nms-patches/HandshakeListener.patch | 14 ++++++++++--- nms-patches/PacketDataSerializer.patch | 16 +++++++++------ nms-patches/PacketEncoder.patch | 27 ++++++++++++++++++++++++++ nms-patches/PacketPlayOutLogin.patch | 17 ++++++++++++++++ nms-patches/PacketStatusListener.patch | 8 ++++++-- 5 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 nms-patches/PacketEncoder.patch create mode 100644 nms-patches/PacketPlayOutLogin.patch diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch index f3340f590e..4798ca8aaf 100644 --- a/nms-patches/HandshakeListener.patch +++ b/nms-patches/HandshakeListener.patch @@ -18,10 +18,17 @@ private final MinecraftServer a; private final NetworkManager b; -@@ -16,6 +26,41 @@ +@@ -11,12 +21,48 @@ + } + + public void a(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) { ++ this.b.channel.pipeline().get(PacketEncoder.class).version = packethandshakinginsetprotocol.b(); // CraftBukkit + switch (HandshakeListener.SyntheticClass_1.a[packethandshakinginsetprotocol.a().ordinal()]) { + case 1: this.b.setProtocol(EnumProtocol.LOGIN); ChatComponentText chatcomponenttext; +- if (packethandshakinginsetprotocol.b() > 107) { + // CraftBukkit start - Connection throttle + try { + long currentTime = System.currentTimeMillis(); @@ -57,10 +64,11 @@ + } + // CraftBukkit end + - if (packethandshakinginsetprotocol.b() > 107) { ++ if (packethandshakinginsetprotocol.b() > 108) { chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.9"); this.b.sendPacket(new PacketLoginOutDisconnect(chatcomponenttext)); -@@ -26,6 +71,7 @@ + this.b.close(chatcomponenttext); +@@ -26,6 +72,7 @@ this.b.close(chatcomponenttext); } else { this.b.setPacketListener(new LoginListener(this.a, this.b)); diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch index 010ab30249..d15d36df42 100644 --- a/nms-patches/PacketDataSerializer.patch +++ b/nms-patches/PacketDataSerializer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PacketDataSerializer.java +++ b/net/minecraft/server/PacketDataSerializer.java -@@ -20,6 +20,8 @@ +@@ -20,9 +20,12 @@ import java.nio.charset.Charset; import java.util.UUID; @@ -9,7 +9,11 @@ public class PacketDataSerializer extends ByteBuf { private final ByteBuf a; -@@ -44,8 +46,16 @@ ++ int version = 107; // CraftBukkkit + + public PacketDataSerializer(ByteBuf bytebuf) { + this.a = bytebuf; +@@ -44,8 +47,16 @@ return this; } @@ -27,7 +31,7 @@ this.readBytes(abyte); return abyte; -@@ -99,7 +109,7 @@ +@@ -99,7 +110,7 @@ } public > T a(Class oclass) { @@ -36,7 +40,7 @@ } public PacketDataSerializer a(Enum oenum) { -@@ -176,7 +186,7 @@ +@@ -176,7 +187,7 @@ } else { try { NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); @@ -45,7 +49,7 @@ throw new EncoderException(ioexception); } } -@@ -202,7 +212,7 @@ +@@ -202,7 +213,7 @@ } public PacketDataSerializer a(ItemStack itemstack) { @@ -54,7 +58,7 @@ this.writeShort(-1); } else { this.writeShort(Item.getId(itemstack.getItem())); -@@ -230,6 +240,11 @@ +@@ -230,6 +241,11 @@ itemstack = new ItemStack(Item.getById(short0), b0, short1); itemstack.setTag(this.j()); diff --git a/nms-patches/PacketEncoder.patch b/nms-patches/PacketEncoder.patch new file mode 100644 index 0000000000..27915625e2 --- /dev/null +++ b/nms-patches/PacketEncoder.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/server/PacketEncoder.java ++++ b/net/minecraft/server/PacketEncoder.java +@@ -14,6 +14,7 @@ + private static final Logger a = LogManager.getLogger(); + private static final Marker b = MarkerManager.getMarker("PACKET_SENT", NetworkManager.b); + private final EnumProtocolDirection c; ++ int version; // CraftBukkit + + public PacketEncoder(EnumProtocolDirection enumprotocoldirection) { + this.c = enumprotocoldirection; +@@ -30,6 +31,7 @@ + throw new IOException("Can\'t serialize unregistered packet"); + } else { + PacketDataSerializer packetdataserializer = new PacketDataSerializer(bytebuf); ++ packetdataserializer.version = version; // CraftBukkit + + packetdataserializer.b(integer.intValue()); + +@@ -42,7 +44,7 @@ + } + } + +- protected void encode(ChannelHandlerContext channelhandlercontext, Object object, ByteBuf bytebuf) throws Exception { ++ protected void encode(ChannelHandlerContext channelhandlercontext, Packet object, ByteBuf bytebuf) throws Exception { + this.a(channelhandlercontext, (Packet) object, bytebuf); + } + } diff --git a/nms-patches/PacketPlayOutLogin.patch b/nms-patches/PacketPlayOutLogin.patch new file mode 100644 index 0000000000..4fcf2a76ba --- /dev/null +++ b/nms-patches/PacketPlayOutLogin.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/server/PacketPlayOutLogin.java ++++ b/net/minecraft/server/PacketPlayOutLogin.java +@@ -54,7 +54,13 @@ + } + + packetdataserializer.writeByte(i); +- packetdataserializer.writeByte(this.d); ++ // CraftBukkit start ++ if (packetdataserializer.version < 108) { ++ packetdataserializer.writeByte(this.d); ++ } else { ++ packetdataserializer.writeInt(this.d); ++ } ++ // CraftBukkit end + packetdataserializer.writeByte(this.e.a()); + packetdataserializer.writeByte(this.f); + packetdataserializer.a(this.g.name()); diff --git a/nms-patches/PacketStatusListener.patch b/nms-patches/PacketStatusListener.patch index e660bf8bd0..90ef226101 100644 --- a/nms-patches/PacketStatusListener.patch +++ b/nms-patches/PacketStatusListener.patch @@ -17,7 +17,7 @@ public class PacketStatusListener implements PacketStatusInListener { private static final IChatBaseComponent a = new ChatComponentText("Status request has been handled."); -@@ -19,8 +30,95 @@ +@@ -19,8 +30,99 @@ this.networkManager.close(PacketStatusListener.a); } else { this.d = true; @@ -106,7 +106,11 @@ + ping.setFavicon(event.icon.value); + ping.setMOTD(new ChatComponentText(event.getMotd())); + ping.setPlayerSample(playerSample); -+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), minecraftServer.getServerPing().getServerData().getProtocolVersion())); ++ int version = minecraftServer.getServerPing().getServerData().getProtocolVersion(); ++ if (this.networkManager.channel.pipeline().get(PacketEncoder.class).version == 108) { ++ version = 108; ++ } ++ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version)); + + this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping)); }