Skip to content

Commit 1fabb81

Browse files
committed
Add identity checks to NBTCodecImpl builder methods
1 parent 87d9050 commit 1fabb81

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎src/main/java/org/glavo/nbt/internal/NBTCodecImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ public void writeTag(Tag tag, WritableByteChannel channel) throws IOException {
272272
}
273273

274274
@Override
275-
public ChunkRegion readRegion(Path path) throws IOException {
275+
public ChunkRegion readRegion(Path path, OversizedChunkAccessor accessor) throws IOException {
276276
try (var channel = FileChannel.open(path, StandardOpenOption.READ);
277277
var reader = new RawDataReader(new InputSource.OfByteChannel(channel, true), MinecraftEdition.JAVA_EDITION)) {
278-
return readRegion(reader, oversizedChunkAccessorFactory.apply(path));
278+
return readRegion(reader, accessor);
279279
}
280280
}
281281

‎src/main/java/org/glavo/nbt/io/NBTCodec.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ default <T extends Tag> T readTag(Path path, Class<T> tagClass) throws IOExcepti
156156
void writeTag(Tag tag, WritableByteChannel channel) throws IOException;
157157

158158
/// Reads a chunk region from a file.
159-
ChunkRegion readRegion(Path path) throws IOException;
159+
default ChunkRegion readRegion(Path path) throws IOException {
160+
return readRegion(path, getOversizedChunkAccessorFactory().apply(path));
161+
}
162+
163+
ChunkRegion readRegion(Path path, OversizedChunkAccessor accessor) throws IOException;
160164

161165
/// Reads a chunk region from an input stream.
162166
default ChunkRegion readRegion(InputStream inputStream) throws IOException {

0 commit comments

Comments
 (0)