From 95a269df7af4cb1d17b473662f4f3ae37b73b885 Mon Sep 17 00:00:00 2001 From: Shane Date: Mon, 14 Nov 2016 19:27:44 +0000 Subject: [PATCH] Fix handling of Title packet for 1.11 and maintain backwards compat with 1.10 and earlier --- .../md_5/bungee/protocol/packet/Title.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Title.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Title.java index 79a12578..5e93e28d 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Title.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Title.java @@ -28,11 +28,20 @@ public class Title extends DefinedPacket @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - action = Action.values()[readVarInt( buf )]; + int index = readVarInt( buf ); + + // If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value. + if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_10 && index <= 2 ) + { + index++; + } + + action = Action.values()[index]; switch ( action ) { case TITLE: case SUBTITLE: + case ACTIONBAR: text = readString( buf ); break; case TIMES: @@ -46,11 +55,20 @@ public class Title extends DefinedPacket @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - writeVarInt( action.ordinal(), buf ); + int index = readVarInt( buf ); + + // If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value. + if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_10 && index <= 2 ) + { + index++; + } + + action = Action.values()[index]; switch ( action ) { case TITLE: case SUBTITLE: + case ACTIONBAR: writeString( text, buf ); break; case TIMES: @@ -72,6 +90,7 @@ public class Title extends DefinedPacket TITLE, SUBTITLE, + ACTIONBAR, TIMES, CLEAR, RESET