Search in sources :

Example 1 with LimitInputStream

use of org.lanternpowered.server.util.io.LimitInputStream in project LanternServer by LanternPowered.

the class LanternByteBuffer method readLimitedDataView.

@Nullable
@Override
public DataView readLimitedDataView(int maximumDepth, int maxBytes) {
    final int index = this.buf.readerIndex();
    if (this.buf.readByte() == 0) {
        return null;
    }
    this.buf.readerIndex(index);
    try {
        try (NbtDataContainerInputStream input = new NbtDataContainerInputStream(new LimitInputStream(new ByteBufInputStream(this.buf), maxBytes), false, maximumDepth)) {
            return input.read();
        }
    } catch (IOException e) {
        throw new CodecException(e);
    }
}
Also used : NbtDataContainerInputStream(org.lanternpowered.server.data.persistence.nbt.NbtDataContainerInputStream) CodecException(io.netty.handler.codec.CodecException) LimitInputStream(org.lanternpowered.server.util.io.LimitInputStream) ByteBufInputStream(io.netty.buffer.ByteBufInputStream) IOException(java.io.IOException) Nullable(javax.annotation.Nullable)

Aggregations

ByteBufInputStream (io.netty.buffer.ByteBufInputStream)1 CodecException (io.netty.handler.codec.CodecException)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1 NbtDataContainerInputStream (org.lanternpowered.server.data.persistence.nbt.NbtDataContainerInputStream)1 LimitInputStream (org.lanternpowered.server.util.io.LimitInputStream)1