From 841c81cdc4ce3267ce660bbcc8ec0249602a4ea1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 24 Jan 2016 19:45:02 +1100 Subject: [PATCH] [#1714] Make a copy of the main Minecraft buffer as EntityMap.rewriteVarInt may require more bytes than available. --- .../main/java/net/md_5/bungee/protocol/MinecraftDecoder.java | 2 +- proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java | 2 +- .../main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java index 7911953d..5719e188 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -21,7 +21,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT; - ByteBuf slice = in.slice().retain(); + ByteBuf slice = in.copy(); // Can't slice this one due to EntityMap :( try { 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 819ba3f4..1eda3adb 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 @@ -88,7 +88,7 @@ public abstract class EntityMap int readIdLength = packet.readerIndex() - offset; if ( readId == oldId || readId == newId ) { - ByteBuf data = packet.slice().copy(); + ByteBuf data = packet.copy(); packet.readerIndex( offset ); packet.writerIndex( offset ); DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet ); diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java index 67091434..301da0e7 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java @@ -37,7 +37,7 @@ class EntityMap_1_7_6 extends EntityMap_1_7_2 if ( profile != null && profile.getProperties() != null && profile.getProperties().length >= 1 ) { - ByteBuf rest = packet.slice().copy(); + ByteBuf rest = packet.copy(); packet.readerIndex( readerIndex ); packet.writerIndex( readerIndex + packetIdLength + idLength ); DefinedPacket.writeString( player.getUniqueId().toString(), packet );