mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 06:57:28 +02:00
Lazily initialize nbtReader
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
acc711c640
commit
ca6f0b1eb5
@ -28,7 +28,7 @@ import java.util.function.Supplier;
|
|||||||
*/
|
*/
|
||||||
public class BinaryReader extends InputStream {
|
public class BinaryReader extends InputStream {
|
||||||
private final ByteBuffer buffer;
|
private final ByteBuffer buffer;
|
||||||
private final NBTReader nbtReader = new NBTReader(this, false);
|
private NBTReader nbtReader;
|
||||||
|
|
||||||
public BinaryReader(@NotNull ByteBuffer buffer) {
|
public BinaryReader(@NotNull ByteBuffer buffer) {
|
||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
@ -235,7 +235,12 @@ public class BinaryReader extends InputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NBT readTag() throws IOException, NBTException {
|
public NBT readTag() throws IOException, NBTException {
|
||||||
return nbtReader.read();
|
NBTReader reader = this.nbtReader;
|
||||||
|
if (reader == null) {
|
||||||
|
reader = new NBTReader(this, false);
|
||||||
|
this.nbtReader = reader;
|
||||||
|
}
|
||||||
|
return reader.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user