From 3373eb864de9a983d5370744c5f6bfb8ff56b7fb Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 May 2020 15:41:38 +1000 Subject: [PATCH] #2834: Add support for long array NBT tag --- proxy/pom.xml | 12 +++++------ .../net/md_5/bungee/entitymap/EntityMap.java | 21 ++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/proxy/pom.xml b/proxy/pom.xml index a682d3c6..c2b454ff 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -24,12 +24,6 @@ - - com.flowpowered - flow-nbt - 1.0.0 - compile - io.netty netty-codec-haproxy @@ -91,6 +85,12 @@ 5.0.4 compile + + se.llbit + jo-nbt + 1.3.0 + compile + mysql mysql-connector-java 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 b15045f6..fe900fcf 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 @@ -1,14 +1,15 @@ package net.md_5.bungee.entitymap; -import com.flowpowered.nbt.stream.NBTInputStream; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; -import java.io.IOException; +import java.io.DataInputStream; import lombok.AccessLevel; import lombok.NoArgsConstructor; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.ProtocolConstants; +import se.llbit.nbt.NamedTag; +import se.llbit.nbt.Tag; /** * Class to rewrite integers within packets. @@ -252,12 +253,10 @@ public abstract class EntityMap DefinedPacket.readVarInt( packet ); break; case 13: - try + Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) ); + if ( tag.isError() ) { - new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); - } catch ( IOException ex ) - { - throw new RuntimeException( ex ); + throw new RuntimeException( tag.error() ); } break; case 15: @@ -300,12 +299,10 @@ public abstract class EntityMap { packet.readerIndex( position ); - try + Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) ); + if ( tag.isError() ) { - new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); - } catch ( IOException ex ) - { - throw new RuntimeException( ex ); + throw new RuntimeException( tag.error() ); } } }