Search in sources :

Example 1 with NbtReadLimiter

use of net.glowstone.util.nbt.NbtReadLimiter in project Glowstone by GlowstoneMC.

the class GlowBufUtils method readCompound.

private static CompoundTag readCompound(ByteBuf buf, boolean network) {
    int idx = buf.readerIndex();
    if (buf.readByte() == 0) {
        return null;
    }
    buf.readerIndex(idx);
    try (NBTInputStream str = new NBTInputStream(new ByteBufInputStream(buf), false)) {
        return str.readCompound(network ? new NBTReadLimiter(2097152L) : NBTReadLimiter.UNLIMITED);
    } catch (IOException e) {
        return null;
    }
}
Also used : NBTInputStream(net.glowstone.util.nbt.NBTInputStream) NBTReadLimiter(net.glowstone.util.nbt.NBTReadLimiter) ByteBufInputStream(io.netty.buffer.ByteBufInputStream) IOException(java.io.IOException)

Aggregations

ByteBufInputStream (io.netty.buffer.ByteBufInputStream)1 IOException (java.io.IOException)1 NBTInputStream (net.glowstone.util.nbt.NBTInputStream)1 NBTReadLimiter (net.glowstone.util.nbt.NBTReadLimiter)1