mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-01 07:03:52 +01:00
Fix downloaded schems + mcedit
This commit is contained in:
parent
6dfea0364a
commit
911e7e7751
@ -11,12 +11,14 @@ import com.boydti.fawe.object.PseudoRandom;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MemUtil;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
@ -44,6 +46,7 @@ import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -142,10 +145,11 @@ public class FaweAPI {
|
||||
@Override
|
||||
public void run(OutputStream value) {
|
||||
try {
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(value, true);
|
||||
ClipboardWriter writer = format.getWriter(gzip);
|
||||
try (GZIPOutputStream gzip = new GZIPOutputStream(value, true)) {
|
||||
try (ClipboardWriter writer = format.getWriter(gzip)) {
|
||||
writer.write(clipboard, null);
|
||||
gzip.flush();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.boydti.fawe.object.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class AbstractDelegateOutputStream extends OutputStream {
|
||||
private final OutputStream parent;
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
parent.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
parent.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
parent.write(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
parent.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
parent.close();
|
||||
}
|
||||
|
||||
public AbstractDelegateOutputStream(OutputStream os) {
|
||||
this.parent = os;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet;
|
||||
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
|
||||
import com.boydti.fawe.object.io.AbstractDelegateOutputStream;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.DoubleTag;
|
||||
import com.sk89q.jnbt.EndTag;
|
||||
@ -281,7 +282,11 @@ public class MainUtil {
|
||||
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(CRLF);
|
||||
writer.append("Content-Transfer-Encoding: binary").append(CRLF);
|
||||
writer.append(CRLF).flush();
|
||||
writeTask.value = output;
|
||||
OutputStream nonClosable = new AbstractDelegateOutputStream(output) {
|
||||
@Override
|
||||
public void close() throws IOException { } // Don't close
|
||||
};
|
||||
writeTask.value = nonClosable;
|
||||
writeTask.run();
|
||||
output.flush();
|
||||
writer.append(CRLF).flush();
|
||||
|
Loading…
Reference in New Issue
Block a user