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;
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations