mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 11:26:42 +00:00
Renaming and cleanup and a new method.
This commit is contained in:
@ -50,9 +50,8 @@ public final class NBTInputStream implements Closeable {
|
||||
* from the specified input stream.
|
||||
*
|
||||
* @param is the input stream
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public NBTInputStream(InputStream is) throws IOException {
|
||||
public NBTInputStream(InputStream is) {
|
||||
this.is = new DataInputStream(is);
|
||||
}
|
||||
|
||||
@ -152,39 +151,21 @@ public final class NBTInputStream implements Closeable {
|
||||
if (reader instanceof NBTStreamer.ByteReader) {
|
||||
NBTStreamer.ByteReader byteReader = (NBTStreamer.ByteReader) reader;
|
||||
int i = 0;
|
||||
if (is instanceof InputStream) {
|
||||
DataInputStream dis = is;
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
dis.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
DataInputStream dis = is;
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
dis.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, dis.read());
|
||||
}
|
||||
} else {
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
is.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, is.readByte() & 0xFF);
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, dis.read());
|
||||
}
|
||||
} else if (reader instanceof NBTStreamer.LazyReader) {
|
||||
reader.accept(length, is);
|
||||
@ -382,7 +363,7 @@ public final class NBTInputStream implements Closeable {
|
||||
int toRead = Math.min(length << 2, buf.length);
|
||||
is.readFully(buf, 0, toRead);
|
||||
for (int i = 0; i < toRead; i += 4, index++) {
|
||||
data[index] = ((buf[i + 0] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
|
||||
data[index] = ((buf[i] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
|
||||
}
|
||||
length -= toRead;
|
||||
}
|
||||
@ -583,7 +564,7 @@ public final class NBTInputStream implements Closeable {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (is instanceof AutoCloseable) {
|
||||
if (is != null) {
|
||||
try {
|
||||
((AutoCloseable) is).close();
|
||||
} catch (Exception e) {
|
||||
|
Reference in New Issue
Block a user