Class TStreamTools
java.lang.Object
com.saicone.rtag.stream.TStreamTools
Class to invoke NbtIo methods across versions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic DataInputStreamgetDataInput(InputStream input) Get the required data input stream to read.
This method will use the new enhanced FastBufferedInputStream if the server version is 1.18 or higher, so this method checks if the provided InputStream is GZIP formatted to parse it correctly.static DataInputStreamgetDataInput(InputStream input, boolean gzip) Get the required data input stream to read.
This method will use the new enhanced FastBufferedInputStream if the server version is 1.18 or higher.static ObjectGet a NbtAccounter instance with no limit to read NBT data.static booleanisGzipFormat(File file) Check if the provided file is a GZIP file.static booleanisGzipFormat(InputStream input) Check if the provided InputStream is a GZIP formatted input.static booleanisGzipHeader(byte[] bytes) Check if the provided byte array has GZIP header.static booleanisGzipHeader(int ID1, int ID2) Check if the provided ID1 and ID2 are the same has GZIP magic.static booleanisNbtHeader(byte[] bytes) Check if the provided byte array has NBT header.static Objectread(byte[] bytes) Read Tag from byte array.static ObjectRead Tag from DataInput.static Objectread(DataInputStream input) Read Tag from DataInputStream.static ObjectRead Tag from file.static Objectread(InputStream input) Read Tag from InputStream.static voidwrite(Object tag, DataOutput output) Write Tag to DataOutput.static voidwrite(Object tag, DataOutputStream output) Write Tag to DataOutputStream.static voidWrite Tag to File.static voidwrite(Object tag, OutputStream output) Write Tag to OutputStream.
-
Method Details
-
getReadLimiter
Get a NbtAccounter instance with no limit to read NBT data.- Returns:
- A NbtAccounter instance.
-
getDataInput
Get the required data input stream to read.
This method will use the new enhanced FastBufferedInputStream if the server version is 1.18 or higher, so this method checks if the provided InputStream is GZIP formatted to parse it correctly.- Parameters:
input- The InputStream to parse.- Returns:
- A parsed input stream.
- Throws:
IOException- if an I/O error occurs.
-
getDataInput
Get the required data input stream to read.
This method will use the new enhanced FastBufferedInputStream if the server version is 1.18 or higher.- Parameters:
input- The InputStream to parse.gzip- Set to true if the InputStream is on GZIP format.- Returns:
- A parsed input stream.
- Throws:
IOException- if an I/O error occurs.
-
isGzipFormat
Check if the provided file is a GZIP file.- Parameters:
file- The file to check.- Returns:
- true if the file is GZIP formatted, false otherwise.
- Throws:
IOException- if an I/O error occurs.
-
isGzipFormat
Check if the provided InputStream is a GZIP formatted input.- Parameters:
input- The InputStream to check.- Returns:
- true if the input stream is GZIP formatted, false otherwise.
- Throws:
IOException- if an I/O error occurs.
-
isGzipHeader
public static boolean isGzipHeader(byte[] bytes) Check if the provided byte array has GZIP header.- Parameters:
bytes- The byte array to check.- Returns:
- true if it contains GZIP header.
-
isGzipHeader
public static boolean isGzipHeader(int ID1, int ID2) Check if the provided ID1 and ID2 are the same has GZIP magic.- Parameters:
ID1- The first ID.ID2- The second ID.- Returns:
- true if the IDs are the same has GZIP magic.
-
isNbtHeader
public static boolean isNbtHeader(byte[] bytes) Check if the provided byte array has NBT header.- Parameters:
bytes- The byte array to check.- Returns:
- true of it contains NBT header.
-
read
Read Tag from file.- Parameters:
file- File to read.- Returns:
- A Tag instance.
- Throws:
IOException- if root object is not a nbt tag.
-
read
Read Tag from byte array.- Parameters:
bytes- The byte array to read.- Returns:
- A Tag instance.
- Throws:
IOException- if root object is not a nbt tag.
-
read
Read Tag from InputStream.- Parameters:
input- InputStream to read.- Returns:
- A Tag instance.
- Throws:
IOException- if root object is not a nbt tag.
-
read
Read Tag from DataInputStream.- Parameters:
input- DataInputStream to read.- Returns:
- A Tag instance.
- Throws:
IOException- if root object is not a nbt tag.
-
read
Read Tag from DataInput.- Parameters:
input- DataInput to read.- Returns:
- A Tag instance.
- Throws:
IOException- if root object is not a nbt tag.
-
write
Write Tag to File.- Parameters:
tag- The tag to write.file- File to write in.- Throws:
IOException- if an I/O error occurs while writing.
-
write
Write Tag to OutputStream.- Parameters:
tag- The tag to write.output- OutputStream to write in.- Throws:
IOException- if an I/O error occurs while writing.
-
write
Write Tag to DataOutputStream.- Parameters:
tag- The tag to write.output- DataOutputStream to write in.- Throws:
IOException- if an I/O error occurs while writing.
-
write
Write Tag to DataOutput.- Parameters:
tag- The tag to write.output- DataOutput to write in.- Throws:
IOException- if an I/O error occurs while writing.
-