Examples of NBTOutputStream


Examples of com.iCo6.util.nbt.NBTOutputStream

            HashMap<String, Tag> tagCompound = new HashMap<String, Tag>(tag.getValue());
            tagCompound.put("Inventory", inventory);
            tag = new CompoundTag("Player", tagCompound);

            NBTOutputStream out = new NBTOutputStream(new FileOutputStream(new File(dataDir, name + ".dat")));
            out.writeTag(tag);
            out.close();
        } catch (IOException ex) {
            iConomy.Server.getLogger().log(Level.WARNING, "[iCo/InvDB] error writing inventory {0}: {1}", new Object[]{name, ex.getMessage()});
        }
    }
View Full Code Here

Examples of com.sk89q.jnbt.NBTOutputStream

            schematic.put("AddBlocks", new ByteArrayTag(addBlocks));
        }

        // Build and output
        CompoundTag schematicTag = new CompoundTag(schematic);
        NBTOutputStream stream = new NBTOutputStream(new GZIPOutputStream(new FileOutputStream(file)));
        stream.writeNamedTag("Schematic", schematicTag);
        stream.close();
    }
View Full Code Here

Examples of net.glowstone.util.nbt.NBTOutputStream

            buf.writeByte(0);
            return;
        }

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try (NBTOutputStream str = new NBTOutputStream(out, false)) {
            str.writeTag(data);
        } catch (IOException e) {
            GlowServer.logger.log(Level.WARNING, "Error serializing NBT: " + data, e);
            return;
        }
View Full Code Here

Examples of net.glowstone.util.nbt.NBTOutputStream

        levelTags.putCompoundList("TileEntities", tileEntities);

        CompoundTag levelOut = new CompoundTag();
        levelOut.putCompound("Level", levelTags);

        try (NBTOutputStream nbt = new NBTOutputStream(region.getChunkDataOutputStream(regionX, regionZ), false)) {
            nbt.writeTag(levelOut);
        }
    }
View Full Code Here

Examples of net.glowstone.util.nbt.NBTOutputStream

        // Not sure how to calculate this, so ignoring for now
        out.putLong("SizeOnDisk", 0);

        CompoundTag root = new CompoundTag();
        root.putCompound("Data", out);
        try (NBTOutputStream nbtOut = new NBTOutputStream(new FileOutputStream(new File(dir, "level.dat")))) {
            nbtOut.writeTag(root);
        } catch (IOException e) {
            handleWorldException("level.dat", e);
        }
    }
View Full Code Here

Examples of net.glowstone.util.nbt.NBTOutputStream

    @Override
    public void writeData(GlowPlayer player) {
        File playerFile = getPlayerFile(player.getUniqueId());
        CompoundTag tag = new CompoundTag();
        EntityStorage.save(player, tag);
        try (NBTOutputStream out = new NBTOutputStream(new FileOutputStream(playerFile))) {
            out.writeTag(tag);
        } catch (IOException e) {
            player.kickPlayer("Failed to save player data!");
            server.getLogger().log(Level.SEVERE, "Failed to write data for " + player.getName() + ": " + playerFile, e);
        }
    }
View Full Code Here

Examples of net.lightstone.util.nbt.NBTOutputStream

    int regionX = x & (REGION_SIZE - 1);
    int regionZ = z & (REGION_SIZE - 1);

    DataOutputStream out = region.getChunkDataOutputStream(regionX, regionZ);
    try {
      NBTOutputStream nbtOut = new NBTOutputStream(out, false);

      Map<String, Tag> tagMap = new HashMap<String, Tag>(1);
      tagMap.put("Level", levelTag);

      CompoundTag tag = new CompoundTag("", tagMap);
      nbtOut.writeTag(tag);
    } finally {
      out.close();
    }

    // TODO: Close the regionfile
View Full Code Here

Examples of org.jnbt.NBTOutputStream

      final CompoundTag newDataTag = new CompoundTag("Data", newData);
      final Map<String, Tag> newTopLevelMap = new HashMap<String, Tag>(1);
      newTopLevelMap.put("Data", newDataTag);
      final CompoundTag newTopLevelTag = new CompoundTag("", newTopLevelMap);

      final NBTOutputStream output = new NBTOutputStream(new FileOutputStream(level));
      output.writeTag(newTopLevelTag);
      output.close();
    } catch (final ClassCastException ex) {
      throw new IOException("Invalid level format.");
    } catch (final NullPointerException ex) {
      throw new IOException("Invalid level format.");
    }
View Full Code Here

Examples of org.jnbt.NBTOutputStream

        posTag.set(0, new DoubleTag("x", x));
        posTag.set(1, new DoubleTag("y", 120));
        posTag.set(2, new DoubleTag("z", y));
        rootMap.put("Pos", new ListTag("Pos", DoubleTag.class, posTag));
        root = new CompoundTag("Data", rootMap);
        NBTOutputStream outStream = new NBTOutputStream(new FileOutputStream(out));
        outStream.writeTag(root);
        outStream.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
     
    } else {
      out = file;
      backupFile(out);
      try {
        NBTInputStream inStream = new NBTInputStream(new FileInputStream(out));
        CompoundTag root = (CompoundTag)(((CompoundTag)inStream.readTag()).getValue().get("Data"));
        inStream.close();
       
        HashMap<String, Tag> rootMap = new HashMap<String, Tag>(root.getValue());
        HashMap<String, Tag> playerMap = new HashMap<String, Tag>(((CompoundTag)rootMap.get("Player")).getValue());
        ArrayList<Tag> posTag = new ArrayList<Tag>(((ListTag)playerMap.get("Pos")).getValue());
        posTag.set(0, new DoubleTag("x", x));
        posTag.set(1, new DoubleTag("y", 120));
        posTag.set(2, new DoubleTag("z", y));
        rootMap.put("Player", new CompoundTag("Player", playerMap));
        playerMap.put("Pos", new ListTag("Pos", DoubleTag.class, posTag));
        root = new CompoundTag("Data", rootMap);
        HashMap<String, Tag> base = new HashMap<String, Tag>();
        base.put("Data", root);
        root = new CompoundTag("Base", base);
        NBTOutputStream outStream = new NBTOutputStream(new FileOutputStream(out));
        outStream.writeTag(root);
        outStream.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.