mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-03-07 13:48:00 +08:00
Remove requirement for caller to ungzip the stream with the new isFormat API
This commit is contained in:
parent
c7d559bfcc
commit
da4bca05f2
@ -71,9 +71,7 @@ public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
||||
public boolean isFormat(InputStream inputStream) {
|
||||
LinRootEntry rootEntry;
|
||||
try {
|
||||
DataInputStream stream = inputStream instanceof DataInputStream dataInputStream
|
||||
? dataInputStream
|
||||
: new DataInputStream(inputStream);
|
||||
DataInputStream stream = new DataInputStream(new GZIPInputStream(inputStream));
|
||||
rootEntry = LinBinaryIO.readUsing(stream, LinRootEntry::readFrom);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
@ -155,9 +153,7 @@ public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
||||
public boolean isFormat(InputStream inputStream) {
|
||||
LinCompoundTag root;
|
||||
try {
|
||||
DataInputStream stream = inputStream instanceof DataInputStream dataInputStream
|
||||
? dataInputStream
|
||||
: new DataInputStream(inputStream);
|
||||
DataInputStream stream = new DataInputStream(new GZIPInputStream(inputStream));
|
||||
root = LinBinaryIO.readUsing(stream, LinRootEntry::readFrom).value();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
@ -178,9 +174,7 @@ public boolean isFormat(InputStream inputStream) {
|
||||
private static boolean detectOldSpongeSchematic(InputStream inputStream, int version) {
|
||||
LinRootEntry rootEntry;
|
||||
try {
|
||||
DataInputStream stream = inputStream instanceof DataInputStream dataInputStream
|
||||
? dataInputStream
|
||||
: new DataInputStream(inputStream);
|
||||
DataInputStream stream = new DataInputStream(new GZIPInputStream(inputStream));
|
||||
rootEntry = LinBinaryIO.readUsing(stream, LinRootEntry::readFrom);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
@ -84,7 +84,6 @@ default boolean isFormat(File file) {
|
||||
* @apiNote The caller is responsible for the following:
|
||||
* <ul>
|
||||
* <li>Closing the input stream</li>
|
||||
* <li>Ensuring the data is directly readable, such as not being in GZip format</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param inputStream The stream
|
||||
|
@ -105,8 +105,6 @@ public static ClipboardFormat findByFile(File file) {
|
||||
/**
|
||||
* Detect the format of a given input stream.
|
||||
*
|
||||
* @apiNote The caller is responsible for ensuring the stream is in a readable format, such as removing GZip compression.
|
||||
*
|
||||
* @param inputStreamSupplier The input stream supplier
|
||||
* @return the format, otherwise null if one cannot be detected
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user