Loading Schematics

Discussion in 'Plugin Development' started by SoS_Dylan, Nov 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    SoS_Dylan

    I need to return as Schematic.
    Code:java
    1. public static Schematic loadScheamtic(File file) {
    2. try {
    3. if (file.exists()) {
    4. NBTInputStream nbtStream = new NBTInputStream(new FileInputStream(file));
    5. CompoundTag compound = (CompoundTag) nbtStream.readTag(); // ERROR
    6. Map<String, Tag> tags = compound.getValue();
    7. Short width = (Short) (tags.get("Width")).getValue();
    8. Short height = (Short) (tags.get("Height")).getValue();
    9. Short length = (Short) (tags.get("Length")).getValue();
    10.  
    11. String materials = (String) (tags.get("Materials")).getValue();
    12.  
    13. byte[] blocks = (byte[]) (tags.get("Blocks")).getValue();
    14. byte[] data = (byte[]) (tags.get("Data")).getValue();
    15.  
    16. nbtStream.close();
    17.  
    18. return new Schematic(file.getName().replace(".schematic", ""), width.shortValue(), height.shortValue(), length.shortValue(), materials, blocks, data);
    19. }
    20. } catch (Exception e) {
    21. SkyWars.getInstance().getLogger().severe("Failed to load the schematic: " + file.getAbsolutePath());
    22. e.printStackTrace();
    23. }
    24.  
    25. return null;
    26. }

    Code:
    [SkyWars] Failed to load the schematic: C:\Users\Dylan\Desktop\SkyWars\plugins\SkyWars\maps\Map3-schematic.schematic
    2013-11-17 12:59:02 [SEVERE] java.io.EOFException
    2013-11-17 12:59:02 [SEVERE]at java.io.DataInputStream.readFully(Unknown Source)
    2013-11-17 12:59:02 [SEVERE]at java.io.DataInputStream.readFully(Unknown Source)
    2013-11-17 12:59:02 [SEVERE]at com.sk89q.jnbt.NBTInputStream.readTag(NBTInputStream.java:122)
    2013-11-17 12:59:02 [SEVERE]at com.sk89q.jnbt.NBTInputStream.readTag(NBTInputStream.java:103)
    2013-11-17 12:59:02 [SEVERE]at me.SoSDylan.SkyWars.schematic.SchematicUtils.loadScheamtic(SchematicUtils.java:32)
    2013-11-17 12:59:02 [SEVERE]at me.SoSDylan.SkyWars.game.map.Map.buildSection(Map.java:106)
    2013-11-17 12:59:02 [SEVERE]at me.SoSDylan.SkyWars.game.map.FFAMap.build(FFAMap.java:44)
    2013-11-17 12:59:02 [SEVERE]at me.SoSDylan.SkyWars.game.arena.Arena.start(Arena.java:143)
    2013-11-17 12:59:02 [SEVERE]at me.SoSDylan.SkyWars.timers.ArenaStartCountdown$1.run(ArenaStartCountdown.java:46)
    2013-11-17 12:59:02 [SEVERE]at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftTask.run(CraftTask.java:58)
    2013-11-17 12:59:02 [SEVERE]at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:345)
    2013-11-17 12:59:02 [SEVERE]at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:520)
    2013-11-17 12:59:02 [SEVERE]at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:240)
    2013-11-17 12:59:02 [SEVERE]at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:483)
    2013-11-17 12:59:02 [SEVERE]at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:415)
    2013-11-17 12:59:02 [SEVERE]at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    2013-11-17 12:59:02
     
  2. Offline

    The_Doctor_123

    Looks like the file data is unexpectedly ending.
     
  3. Offline

    SoS_Dylan

    Do you know how you would fix it?
     
  4. Offline

    Garris0n

    Which line is 32?
     
  5. Offline

    SoS_Dylan

    Garris0n
    Code:java
    1. CompoundTag compound = (CompoundTag) nbtStream.readTag(); // ERROR
     
  6. Offline

    Garris0n

    Are you sure the file exists and has schematic data in it? Try putting it in the w.e. schematic folder and loading it with w.e. to make sure it works.
     
Thread Status:
Not open for further replies.

Share This Page