Search in sources :

Example 1 with NBTOutputStream

use of com.sk89q.jnbt.NBTOutputStream in project FastAsyncWorldEdit by IntellectualSites.

the class FaweDelegateSchematicHandler method save.

public boolean save(CompoundTag tag, String path) {
    if (tag == null) {
        LOGGER.warn("Cannot save empty tag");
        return false;
    }
    try {
        File tmp = FileUtils.getFile(PlotSquared.platform().getDirectory(), path);
        tmp.getParentFile().mkdirs();
        if (tag instanceof CompressedCompoundTag) {
            CompressedCompoundTag cTag = (CompressedCompoundTag) tag;
            if (cTag instanceof CompressedSchematicTag) {
                Clipboard clipboard = (Clipboard) cTag.getSource();
                try (OutputStream stream = new FileOutputStream(tmp);
                    NBTOutputStream output = new NBTOutputStream(new BufferedOutputStream(new ParallelGZIPOutputStream(stream)))) {
                    new FastSchematicWriter(output).write(clipboard);
                }
            } else {
                try (OutputStream stream = new FileOutputStream(tmp);
                    BufferedOutputStream output = new BufferedOutputStream(new ParallelGZIPOutputStream(stream))) {
                    LZ4BlockInputStream is = cTag.adapt(cTag.getSource());
                    IOUtil.copy(is, output);
                }
            }
        } else {
            try (OutputStream stream = new FileOutputStream(tmp);
                NBTOutputStream output = new NBTOutputStream(new ParallelGZIPOutputStream(stream))) {
                Map<String, Tag> map = tag.getValue();
                output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
            }
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
Also used : FastSchematicWriter(com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter) CompressedSchematicTag(com.fastasyncworldedit.core.jnbt.CompressedSchematicTag) NBTOutputStream(com.sk89q.jnbt.NBTOutputStream) ParallelGZIPOutputStream(org.anarres.parallelgzip.ParallelGZIPOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) NBTOutputStream(com.sk89q.jnbt.NBTOutputStream) LZ4BlockInputStream(net.jpountz.lz4.LZ4BlockInputStream) CompressedCompoundTag(com.fastasyncworldedit.core.jnbt.CompressedCompoundTag) ParallelGZIPOutputStream(org.anarres.parallelgzip.ParallelGZIPOutputStream) FileOutputStream(java.io.FileOutputStream) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) CompressedSchematicTag(com.fastasyncworldedit.core.jnbt.CompressedSchematicTag) CompressedCompoundTag(com.fastasyncworldedit.core.jnbt.CompressedCompoundTag) CompoundTag(com.sk89q.jnbt.CompoundTag) Tag(com.sk89q.jnbt.Tag) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 2 with NBTOutputStream

use of com.sk89q.jnbt.NBTOutputStream in project FastAsyncWorldEdit by IntellectualSites.

the class FaweStreamChangeSet method addEntityRemove.

@Override
public void addEntityRemove(CompoundTag tag) {
    if (tag == null) {
        return;
    }
    blockSize++;
    try {
        NBTOutputStream nbtos = getEntityRemoveOS();
        nbtos.writeTag(tag);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IOException(java.io.IOException) NBTOutputStream(com.sk89q.jnbt.NBTOutputStream)

Example 3 with NBTOutputStream

use of com.sk89q.jnbt.NBTOutputStream in project FastAsyncWorldEdit by IntellectualSites.

the class DiskStorageHistory method getTileRemoveOS.

@Override
public NBTOutputStream getTileRemoveOS() throws IOException {
    if (osNBTF != null) {
        return osNBTF;
    }
    nbtfFile.getParentFile().mkdirs();
    nbtfFile.createNewFile();
    osNBTF = new NBTOutputStream(getCompressedOS(new FileOutputStream(nbtfFile)));
    return osNBTF;
}
Also used : FileOutputStream(java.io.FileOutputStream) NBTOutputStream(com.sk89q.jnbt.NBTOutputStream)

Example 4 with NBTOutputStream

use of com.sk89q.jnbt.NBTOutputStream in project FastAsyncWorldEdit by IntellectualSites.

the class DiskStorageHistory method getEntityRemoveOS.

@Override
public NBTOutputStream getEntityRemoveOS() throws IOException {
    if (osENTCF != null) {
        return osENTCF;
    }
    entfFile.getParentFile().mkdirs();
    entfFile.createNewFile();
    osENTCF = new NBTOutputStream(getCompressedOS(new FileOutputStream(entfFile)));
    return osENTCF;
}
Also used : FileOutputStream(java.io.FileOutputStream) NBTOutputStream(com.sk89q.jnbt.NBTOutputStream)

Example 5 with NBTOutputStream

use of com.sk89q.jnbt.NBTOutputStream in project FastAsyncWorldEdit by IntellectualSites.

the class DiskStorageHistory method getEntityCreateOS.

@Override
public NBTOutputStream getEntityCreateOS() throws IOException {
    if (osENTCT != null) {
        return osENTCT;
    }
    enttFile.getParentFile().mkdirs();
    enttFile.createNewFile();
    osENTCT = new NBTOutputStream(getCompressedOS(new FileOutputStream(enttFile)));
    return osENTCT;
}
Also used : FileOutputStream(java.io.FileOutputStream) NBTOutputStream(com.sk89q.jnbt.NBTOutputStream)

Aggregations

NBTOutputStream (com.sk89q.jnbt.NBTOutputStream)12 IOException (java.io.IOException)7 FileOutputStream (java.io.FileOutputStream)6 CompoundTag (com.sk89q.jnbt.CompoundTag)3 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)3 LZ4BlockInputStream (net.jpountz.lz4.LZ4BlockInputStream)3 FastSchematicWriter (com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter)2 CompressedCompoundTag (com.fastasyncworldedit.core.jnbt.CompressedCompoundTag)2 CompressedSchematicTag (com.fastasyncworldedit.core.jnbt.CompressedSchematicTag)2 Tag (com.sk89q.jnbt.Tag)2 BufferedOutputStream (java.io.BufferedOutputStream)2 OutputStream (java.io.OutputStream)2 LZ4BlockOutputStream (net.jpountz.lz4.LZ4BlockOutputStream)2 ParallelGZIPOutputStream (org.anarres.parallelgzip.ParallelGZIPOutputStream)2 FastByteArrayOutputStream (com.fastasyncworldedit.core.internal.io.FastByteArrayOutputStream)1 FastByteArraysInputStream (com.fastasyncworldedit.core.internal.io.FastByteArraysInputStream)1 FaweOutputStream (com.fastasyncworldedit.core.internal.io.FaweOutputStream)1 MutableBlockVector3 (com.fastasyncworldedit.core.math.MutableBlockVector3)1 IntArrayTag (com.sk89q.jnbt.IntArrayTag)1 ListTag (com.sk89q.jnbt.ListTag)1