From 40a569e14efabfd30a88ddf02ddd06c087d663c4 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 19 Apr 2018 23:55:03 +1000 Subject: [PATCH] Fixes #976 --- .../object/io/NonCloseableInputStream.java | 56 +++++++++++++++++++ .../object/schematic/visualizer/SchemVis.java | 4 +- .../worldedit/command/PatternCommands.java | 4 +- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 core/src/main/java/com/boydti/fawe/object/io/NonCloseableInputStream.java diff --git a/core/src/main/java/com/boydti/fawe/object/io/NonCloseableInputStream.java b/core/src/main/java/com/boydti/fawe/object/io/NonCloseableInputStream.java new file mode 100644 index 00000000..15751c81 --- /dev/null +++ b/core/src/main/java/com/boydti/fawe/object/io/NonCloseableInputStream.java @@ -0,0 +1,56 @@ +package com.boydti.fawe.object.io; + +import java.io.IOException; +import java.io.InputStream; + +public class NonCloseableInputStream extends InputStream { + + private final InputStream parent; + + public NonCloseableInputStream(InputStream parent) { + this.parent = parent; + } + @Override + public int read() throws IOException { + return parent.read(); + } + + @Override + public int read(byte[] b) throws IOException { + return parent.read(b); + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + return parent.read(b, off, len); + } + + @Override + public long skip(long n) throws IOException { + return parent.skip(n); + } + + @Override + public int available() throws IOException { + return parent.available(); + } + + @Override + public void close() throws IOException { + } + + @Override + public void mark(int readlimit) { + parent.mark(readlimit); + } + + @Override + public void reset() throws IOException { + parent.reset(); + } + + @Override + public boolean markSupported() { + return parent.markSupported(); + } +} diff --git a/core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java b/core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java index af431614..2e6f97f5 100644 --- a/core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java +++ b/core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java @@ -9,6 +9,7 @@ import com.boydti.fawe.object.clipboard.LazyClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.exception.FaweException; +import com.boydti.fawe.object.io.NonCloseableInputStream; import com.boydti.fawe.object.queue.LazyFaweChunk; import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.util.*; @@ -457,7 +458,8 @@ public class SchemVis extends ImmutableVirtualWorld { try (FileInputStream fis = new FileInputStream(cached)) { BlockVector2D dimensions = new BlockVector2D(IOUtil.readVarInt(fis), IOUtil.readVarInt(fis)); try (FaweInputStream in = MainUtil.getCompressedIS(fis)) { - try (NBTInputStream nis = new NBTInputStream(in)) { + NonCloseableInputStream nonCloseable = new NonCloseableInputStream(in); + try (NBTInputStream nis = new NBTInputStream(nonCloseable)) { int numChunks = in.readInt(); for (int i = 0; i < numChunks; i++) { diff --git a/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java b/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java index 0627c8df..e55cc523 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java @@ -96,7 +96,7 @@ public class PatternCommands extends MethodCommands { @Command( aliases = {"#simplex"}, - desc = "Use simplex noise to randomize blocks", + desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE", usage = " ", min = 2, max = 2 @@ -377,7 +377,7 @@ public class PatternCommands extends MethodCommands { @Command( aliases = {"#surfacespread"}, - desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset [0, ). e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard", + desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, )`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard", usage = " ", min = 2, max = 2