WorldEdit reading schematics error

Discussion in 'Spigot Plugin Development' started by Bolt, May 11, 2015.

  1. Hello. I'm trying to read schematics using the WorldEdit API with the SchematicFormat.load() but it throws an error. I debugged it a bit and when I do SchematicFormat.getFormat(), it returns saying that my file isn't a known schematic format. However, I tried opening the same schematic file in MCEdit and it opens perfectly fine. Is this a known issue or is there a workaround for this?

    Loading:
    Code (Text):
    public static CuboidClipboard load(File file) {
           
            try {
                SchematicFormat format = SchematicFormat.getFormat(file);
                System.out.println(format == null);
                CuboidClipboard c = SchematicFormat.MCEDIT.load(file);
                return c;
            } catch (Exception e) {
                e.printStackTrace();
            }
           
            return null;
           
        }
    Stack trace :
    Code (Text):
    [20:58:46] [Server thread/WARN]: java.io.EOFException
    [20:58:46] [Server thread/WARN]:     at java.util.zip.GZIPInputStream.readUByte(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at java.util.zip.GZIPInputStream.readUShort(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at java.util.zip.GZIPInputStream.readHeader(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at java.util.zip.GZIPInputStream.<init>(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at java.util.zip.GZIPInputStream.<init>(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at com.sk89q.worldedit.schematic.MCEditSchematicFormat.load(MCEditSchematicFormat.java:62)
    [20:58:46] [Server thread/WARN]:     at com.sk89q.worldedit.schematic.MCEditSchematicFormat.load(MCEditSchematicFormat.java:200)
    [20:58:46] [Server thread/WARN]:     at com.utils.SchematicParser.load(SchematicParser.java:34)
    [20:58:46] [Server thread/WARN]:     at com.utils.GUIManager.onInventoryClick(GUIManager.java:176)
    [20:58:46] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20:58:46] [Server thread/WARN]:     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at java.lang.reflect.Method.invoke(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301)
    [20:58:46] [Server thread/WARN]:     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [20:58:46] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    [20:58:46] [Server thread/WARN]:     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:1554)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.PacketPlayInWindowClick.a(SourceFile:31)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.PacketPlayInWindowClick.a(SourceFile:9)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13)
    [20:58:46] [Server thread/WARN]:     at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at java.util.concurrent.FutureTask.run(Unknown Source)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:683)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623)
    [20:58:46] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526)
    [20:58:46] [Server thread/WARN]:     at java.lang.Thread.run(Unknown Source)
    [20:58:46] [Server thread/INFO]: Error in reading schematic. Are you sure the file is a schematic and not corrupted?
     
  2. Nevermind. Sorry. I just found out now that it was pointing to a different file.