Search in sources :

Example 1 with MCEditSchematicReader

use of com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader in project FastAsyncWorldEdit by IntellectualSites.

the class FaweDelegateSchematicHandler method getSchematic.

public Schematic getSchematic(@Nonnull InputStream is) {
    try {
        FastSchematicReader schematicReader = new FastSchematicReader(new NBTInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(is)))));
        Clipboard clip = schematicReader.read();
        return new Schematic(clip);
    } catch (IOException e) {
        if (e instanceof EOFException) {
            e.printStackTrace();
            return null;
        }
        try {
            SpongeSchematicReader schematicReader = new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
            Clipboard clip = schematicReader.read();
            return new Schematic(clip);
        } catch (IOException e2) {
            if (e2 instanceof EOFException) {
                e.printStackTrace();
                return null;
            }
            try {
                MCEditSchematicReader schematicReader = new MCEditSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
                Clipboard clip = schematicReader.read();
                return new Schematic(clip);
            } catch (IOException e3) {
                LOGGER.warn("{} | {} : {}", is, is.getClass().getCanonicalName(), e.getMessage());
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) SpongeSchematicReader(com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader) BufferedInputStream(java.io.BufferedInputStream) FastSchematicReader(com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader) NBTInputStream(com.sk89q.jnbt.NBTInputStream) EOFException(java.io.EOFException) MCEditSchematicReader(com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) IOException(java.io.IOException) Schematic(com.plotsquared.core.plot.schematic.Schematic)

Example 2 with MCEditSchematicReader

use of com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader in project PlotSquared by IntellectualSites.

the class SchematicHandler method getSchematic.

public Schematic getSchematic(@NonNull InputStream is) {
    try {
        SpongeSchematicReader schematicReader = new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
        Clipboard clip = schematicReader.read();
        return new Schematic(clip);
    } catch (IOException ignored) {
        try {
            MCEditSchematicReader schematicReader = new MCEditSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
            Clipboard clip = schematicReader.read();
            return new Schematic(clip);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) SpongeSchematicReader(com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader) NBTInputStream(com.sk89q.jnbt.NBTInputStream) MCEditSchematicReader(com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) IOException(java.io.IOException) Schematic(com.plotsquared.core.plot.schematic.Schematic)

Aggregations

Schematic (com.plotsquared.core.plot.schematic.Schematic)2 NBTInputStream (com.sk89q.jnbt.NBTInputStream)2 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)2 MCEditSchematicReader (com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader)2 SpongeSchematicReader (com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader)2 IOException (java.io.IOException)2 GZIPInputStream (java.util.zip.GZIPInputStream)2 FastSchematicReader (com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader)1 BufferedInputStream (java.io.BufferedInputStream)1 EOFException (java.io.EOFException)1