forked from SteamWar/SteamWar
Update WorldEditWrapper21
This commit is contained in:
@@ -49,39 +49,14 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
|
||||
|
||||
@Override
|
||||
public InputStream getPlayerClipboard(Player player, boolean schemFormat) {
|
||||
ClipboardHolder clipboardHolder;
|
||||
try {
|
||||
clipboardHolder = WorldEditWrapper.getWorldEditPlugin().getSession(player).getClipboard();
|
||||
} catch (EmptyClipboardException e) {
|
||||
throw new NoClipboardException();
|
||||
}
|
||||
|
||||
Clipboard clipboard = clipboardHolder.getClipboard();
|
||||
if(clipboard == null)
|
||||
throw new NoClipboardException();
|
||||
|
||||
PipedOutputStream outputStream = new PipedOutputStream();
|
||||
PipedInputStream inputStream;
|
||||
try {
|
||||
inputStream = new PipedInputStream(outputStream, 4096);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not init piped input stream", e);
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
return WorldEditWrapper.getPlayerClipboard(player, schemFormat, (outputStream, clipboard, clipboardHolder) ->
|
||||
{
|
||||
try {
|
||||
ClipboardFormat.SCHEMATIC.getWriter(outputStream).write(clipboard, clipboardHolder.getWorldData());
|
||||
} catch (IOException e) {
|
||||
Core.getInstance().getLogger().log(Level.SEVERE, "Could not write schematic", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
Core.getInstance().getLogger().log(Level.SEVERE, "Could not close schem writer", e);
|
||||
}
|
||||
}, "SchemWriter").start();
|
||||
|
||||
return inputStream;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +64,7 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
|
||||
WorldData world = new BukkitWorld(player.getWorld()).getWorldData();
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = getClipboard(new GZIPInputStream(is), schemFormat);
|
||||
clipboard = getClipboard(is, schemFormat);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user