Close after write

This commit is contained in:
Jesse Boyd 2016-06-24 16:22:38 +10:00
parent 2c0a47c60f
commit 3f6abb1c6f

View File

@ -9,6 +9,7 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
@ -22,6 +23,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public class Schematic { public class Schematic {
@ -75,7 +77,9 @@ public class Schematic {
public void save(OutputStream stream, ClipboardFormat format) throws IOException { public void save(OutputStream stream, ClipboardFormat format) throws IOException {
checkNotNull(stream); checkNotNull(stream);
checkNotNull(format); checkNotNull(format);
format.getWriter(stream).write(clipboard, clipboard.getRegion().getWorld().getWorldData()); try (ClipboardWriter writer = format.getWriter(stream)) {
writer.write(clipboard, clipboard.getRegion().getWorld().getWorldData());
}
} }
/** /**