#3803: Add NBT module

This commit is contained in:
Outfluencer
2025-05-31 10:16:29 +10:00
committed by md_5
parent bec329352d
commit 41e49dad6b
39 changed files with 1514 additions and 154 deletions

View File

@@ -47,7 +47,6 @@ import net.md_5.bungee.protocol.packet.TabCompleteRequest;
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
import net.md_5.bungee.util.AllowedCharacters;
import se.llbit.nbt.SpecificTag;
public class UpstreamBridge extends PacketHandler
{
@@ -385,7 +384,7 @@ public class UpstreamBridge extends PacketHandler
@Override
public void handle(CustomClickAction customClickAction) throws Exception
{
CustomClickEvent event = new CustomClickEvent( con, customClickAction.getId(), TagUtil.toJson( (SpecificTag) customClickAction.getData() ) );
CustomClickEvent event = new CustomClickEvent( con, customClickAction.getId(), TagUtil.toJson( customClickAction.getData() ) );
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
{
throw CancelSendSignal.INSTANCE;

View File

@@ -4,12 +4,13 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.NamedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
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.
@@ -275,10 +276,13 @@ public abstract class EntityMap
DefinedPacket.readVarInt( packet );
break;
case 13:
Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) );
if ( tag.isError() )
NamedTag tag = new NamedTag();
try
{
throw new RuntimeException( tag.error() );
tag.read( new DataInputStream( new ByteBufInputStream( packet ) ), NBTLimiter.unlimitedSize() );
} catch ( IOException ioException )
{
throw new RuntimeException( ioException );
}
break;
case 15:
@@ -321,10 +325,13 @@ public abstract class EntityMap
{
packet.readerIndex( position );
Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) );
if ( tag.isError() )
NamedTag tag = new NamedTag();
try
{
throw new RuntimeException( tag.error() );
tag.read( new DataInputStream( new ByteBufInputStream( packet ) ), NBTLimiter.unlimitedSize() );
} catch ( IOException ioException )
{
throw new RuntimeException( ioException );
}
}
}