public void save(OutputStream stream, boolean compressed) throws IOException { NBTOutputStream os = new NBTOutputStream(stream, compressed); os.writeTag(new CompoundTag("", save())); }
switch (tag.getType()) { case TAG_END: writeEndTagPayload((EndTag) tag); break; writeByteTagPayload((ByteTag) tag); break; writeShortTagPayload((ShortTag) tag); break; writeIntTagPayload((IntTag) tag); break; writeLongTagPayload((LongTag) tag); break; writeFloatTagPayload((FloatTag) tag); break; writeDoubleTagPayload((DoubleTag) tag); break; writeByteArrayTagPayload((ByteArrayTag) tag); break; writeStringTagPayload((StringTag) tag); break;
public void saveServers(ServerInfo[] servers) throws IOException { if(file.exists()) if(!file.delete()) throw new IOException("Could not overwrite '".concat(file.getAbsolutePath()).concat("'")); final FileOutputStream fos = new FileOutputStream(file); NBTOutputStream nbtOutputStream = new NBTOutputStream(fos, false); ArrayList<CompoundTag> serversList = new ArrayList<CompoundTag>(); for(ServerInfo server : servers){ serversList.add(new CompoundTag("", createCompoundFromServer(server))); } ListTag<CompoundTag> listTag = new ListTag<CompoundTag>("servers", CompoundTag.class, serversList); CompoundTag root = new CompoundTag("", new CompoundMap()); root.getValue().put("servers", listTag); nbtOutputStream.writeTag(root); nbtOutputStream.flush(); fos.flush(); nbtOutputStream.close(); fos.close(); } }
/** * Writes a {@code TAG_Compound} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeCompoundTagPayload(CompoundTag tag) throws IOException { for (Tag<?> childTag : tag.getValue().values()) { writeTag(childTag); } os.writeByte(TagType.TAG_END.getId()); // end tag - better way? }
/** * Writes a {@code TAG_Compound} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeCompoundTagPayload(CompoundTag tag) throws IOException { for (Tag<?> childTag : tag.getValue().values()) { writeTag(childTag); } os.writeByte(TagType.TAG_END.getId()); // end tag - better way? }
switch (tag.getType()) { case TAG_END: writeEndTagPayload((EndTag) tag); break; writeByteTagPayload((ByteTag) tag); break; writeShortTagPayload((ShortTag) tag); break; writeIntTagPayload((IntTag) tag); break; writeLongTagPayload((LongTag) tag); break; writeFloatTagPayload((FloatTag) tag); break; writeDoubleTagPayload((DoubleTag) tag); break; writeByteArrayTagPayload((ByteArrayTag) tag); break; writeStringTagPayload((StringTag) tag); break;
public void save(OutputStream stream, boolean compressed) throws IOException { NBTOutputStream os = new NBTOutputStream(stream, compressed); os.writeTag(new CompoundTag("", save())); }
/** * Writes a {@code TAG_Compound} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeCompoundTagPayload(CompoundTag tag) throws IOException { for (Tag<?> childTag : tag.getValue().values()) { writeTag(childTag); } os.writeByte(TagType.TAG_END.getId()); // end tag - better way? }
switch (tag.getType()) { case TAG_END: writeEndTagPayload((EndTag) tag); break; writeByteTagPayload((ByteTag) tag); break; writeShortTagPayload((ShortTag) tag); break; writeIntTagPayload((IntTag) tag); break; writeLongTagPayload((LongTag) tag); break; writeFloatTagPayload((FloatTag) tag); break; writeDoubleTagPayload((DoubleTag) tag); break; writeByteArrayTagPayload((ByteArrayTag) tag); break; writeStringTagPayload((StringTag) tag); break;
public void save(OutputStream stream, boolean compressed) throws IOException { NBTOutputStream os = new NBTOutputStream(stream, compressed); os.writeTag(new CompoundTag("", save())); }