mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-01-01 14:08:11 +01:00
check file format
This commit is contained in:
parent
5bdc2d6519
commit
049aff4d74
@ -332,48 +332,50 @@ public class SchemVis extends ImmutableVirtualWorld {
|
|||||||
cached.createNewFile();
|
cached.createNewFile();
|
||||||
try (FileInputStream in = new FileInputStream(file)) {
|
try (FileInputStream in = new FileInputStream(file)) {
|
||||||
ClipboardFormat format = ClipboardFormat.findByFile(file);
|
ClipboardFormat format = ClipboardFormat.findByFile(file);
|
||||||
ClipboardReader reader = format.getReader(in);
|
if (format != null) {
|
||||||
Clipboard clipboard = reader.read(worldData);
|
ClipboardReader reader = format.getReader(in);
|
||||||
clipboard.setOrigin(clipboard.getMinimumPoint());
|
Clipboard clipboard = reader.read(worldData);
|
||||||
try {
|
clipboard.setOrigin(clipboard.getMinimumPoint());
|
||||||
MCAQueue queue = new MCAQueue(null, null, false);
|
try {
|
||||||
BlockVector2D dimensions = clipboard.getDimensions().toVector2D().toBlockVector2D();
|
MCAQueue queue = new MCAQueue(null, null, false);
|
||||||
BlockVector2D offset = registerAndGetChunkOffset(dimensions, cached);
|
BlockVector2D dimensions = clipboard.getDimensions().toVector2D().toBlockVector2D();
|
||||||
new Schematic(clipboard).paste(queue, Vector.ZERO, true);
|
BlockVector2D offset = registerAndGetChunkOffset(dimensions, cached);
|
||||||
try (FileOutputStream fos = new FileOutputStream(cached)) {
|
new Schematic(clipboard).paste(queue, Vector.ZERO, true);
|
||||||
IOUtil.writeVarInt(fos, dimensions.getBlockX());
|
try (FileOutputStream fos = new FileOutputStream(cached)) {
|
||||||
IOUtil.writeVarInt(fos, dimensions.getBlockZ());
|
IOUtil.writeVarInt(fos, dimensions.getBlockX());
|
||||||
|
IOUtil.writeVarInt(fos, dimensions.getBlockZ());
|
||||||
|
|
||||||
try (FaweOutputStream cos = MainUtil.getCompressedOS(fos, 2)) {
|
try (FaweOutputStream cos = MainUtil.getCompressedOS(fos, 2)) {
|
||||||
NBTOutputStream nos = new NBTOutputStream((DataOutput) cos);
|
NBTOutputStream nos = new NBTOutputStream((DataOutput) cos);
|
||||||
Collection<FaweChunk> writeChunks = queue.getFaweChunks();
|
Collection<FaweChunk> writeChunks = queue.getFaweChunks();
|
||||||
cos.writeInt(writeChunks.size());
|
cos.writeInt(writeChunks.size());
|
||||||
|
|
||||||
boolean selected = isSelected(file);
|
boolean selected = isSelected(file);
|
||||||
|
|
||||||
for (FaweChunk chunk : writeChunks) {
|
for (FaweChunk chunk : writeChunks) {
|
||||||
MCAChunk mcaChunk = ((MCAChunk) chunk);
|
MCAChunk mcaChunk = ((MCAChunk) chunk);
|
||||||
mcaChunk.write(nos);
|
mcaChunk.write(nos);
|
||||||
mcaChunk.setLoc(this, mcaChunk.getX() + offset.getBlockX(), mcaChunk.getZ() + offset.getBlockZ());
|
mcaChunk.setLoc(this, mcaChunk.getX() + offset.getBlockX(), mcaChunk.getZ() + offset.getBlockZ());
|
||||||
if (Math.abs(mcaChunk.getX()) <= 15 && Math.abs(mcaChunk.getZ()) <= 15) {
|
if (Math.abs(mcaChunk.getX()) <= 15 && Math.abs(mcaChunk.getZ()) <= 15) {
|
||||||
cacheChunk(cached, mcaChunk, selected);
|
cacheChunk(cached, mcaChunk, selected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (System.getProperty("os.name").contains("Windows")) {
|
||||||
if (System.getProperty("os.name").contains("Windows")) {
|
Path path = cached.toPath();
|
||||||
Path path = cached.toPath();
|
Object hidden = java.nio.file.Files.getAttribute(path, "dos:hidden", LinkOption.NOFOLLOW_LINKS);
|
||||||
Object hidden = java.nio.file.Files.getAttribute(path, "dos:hidden", LinkOption.NOFOLLOW_LINKS);
|
if (hidden != null) {
|
||||||
if (hidden != null) {
|
//link file to DosFileAttributes
|
||||||
//link file to DosFileAttributes
|
java.nio.file.Files.setAttribute(path, "dos:hidden", Boolean.TRUE, LinkOption.NOFOLLOW_LINKS);
|
||||||
java.nio.file.Files.setAttribute(path, "dos:hidden", Boolean.TRUE, LinkOption.NOFOLLOW_LINKS);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
DIMENSION_CACHE.put(file, MathMan.pair((short) dimensions.getBlockX(), (short) dimensions.getBlockZ()));
|
DIMENSION_CACHE.put(file, MathMan.pair((short) dimensions.getBlockX(), (short) dimensions.getBlockZ()));
|
||||||
} finally {
|
} finally {
|
||||||
if (clipboard instanceof Closeable) {
|
if (clipboard instanceof Closeable) {
|
||||||
((Closeable) clipboard).close();
|
((Closeable) clipboard).close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user