Fix p2 download

This commit is contained in:
Jesse Boyd 2019-11-12 23:59:05 +00:00
parent 2354c1a845
commit 48929d76f1
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.regions.general.integrations.plotquared; package com.boydti.fawe.regions.general.integrations.plotquared;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard; import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
import com.boydti.fawe.object.io.PGZIPOutputStream; import com.boydti.fawe.object.io.PGZIPOutputStream;
@ -20,6 +21,7 @@ import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicWriter; import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicWriter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
@ -106,12 +108,18 @@ public class FaweSchematicHandler extends SchematicHandler {
com.github.intellectualsites.plotsquared.plot.util.TaskManager.runTask(whenDone); com.github.intellectualsites.plotsquared.plot.util.TaskManager.runTask(whenDone);
return; return;
} }
CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag);
if (weTag instanceof CompressedSchematicTag) {
Clipboard clipboard = ((CompressedSchematicTag) weTag).getSource();
URL url = FaweAPI.upload(clipboard, BuiltInClipboardFormat.SPONGE_SCHEMATIC);
whenDone.run(url);
return;
}
MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() { MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
@Override @Override
public void run(OutputStream output) { public void run(OutputStream output) {
try { try {
try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) { try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) {
CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag);
try (NBTOutputStream nos = new NBTOutputStream(gzip)) { try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
Map<String, Tag> map = weTag.getValue(); Map<String, Tag> map = weTag.getValue();
nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag)); nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag));