Examples of NBTInputStream


Examples of com.iCo6.util.nbt.NBTInputStream

        }
    }

    private ItemStack[] readInventory(String name) {
        try {
            NBTInputStream in = new NBTInputStream(new FileInputStream(new File(dataDir, name + ".dat")));
            CompoundTag tag = (CompoundTag) in.readTag();
            in.close();

            ListTag inventory = (ListTag) tag.getValue().get("Inventory");

            ItemStack[] stacks = new ItemStack[40];
            for (int i = 0; i < inventory.getValue().size(); ++i) {
View Full Code Here

Examples of com.iCo6.util.nbt.NBTInputStream

        }
    }

    private void writeInventory(String name, ItemStack[] stacks) {
        try {
            NBTInputStream in = new NBTInputStream(new FileInputStream(new File(dataDir, name + ".dat")));
            CompoundTag tag = (CompoundTag) in.readTag();
            in.close();

            ArrayList tagList = new ArrayList<Tag>();

            for (int i = 0; i < stacks.length; ++i) {
                if (stacks[i] == null) continue;
View Full Code Here

Examples of com.sk89q.jnbt.NBTInputStream

    @Override
    public CompoundTag getChunkTag(Vector2D position, World world) throws DataException, IOException {
        McRegionReader reader = getReader(position, world.getName());

        InputStream stream = reader.getChunkInputStream(position);
        NBTInputStream nbt = new NBTInputStream(stream);
        Tag tag;

        try {
            tag = nbt.readNamedTag().getTag();
            if (!(tag instanceof CompoundTag)) {
                throw new ChunkStoreException("CompoundTag expected for chunk; got " + tag.getClass().getName());
            }

            Map<String, Tag> children = ((CompoundTag) tag).getValue();
            CompoundTag rootTag = null;

            // Find Level tag
            for (Map.Entry<String, Tag> entry : children.entrySet()) {
                if (entry.getKey().equals("Level")) {
                    if (entry.getValue() instanceof CompoundTag) {
                        rootTag = (CompoundTag) entry.getValue();
                        break;
                    } else {
                        throw new ChunkStoreException("CompoundTag expected for 'Level'; got " + entry.getValue().getClass().getName());
                    }
                }
            }

            if (rootTag == null) {
                throw new ChunkStoreException("Missing root 'Level' tag");
            }

            return rootTag;
        } finally {
            nbt.close();
        }
    }
View Full Code Here

Examples of com.sk89q.jnbt.NBTInputStream

        String folder2 = Integer.toString(divisorMod(z, 64), 36);
        String filename = "c." + Integer.toString(x, 36)
                + "." + Integer.toString(z, 36) + ".dat";

        InputStream stream = getInputStream(folder1, folder2, filename);
        NBTInputStream nbt = new NBTInputStream(
                new GZIPInputStream(stream));
        Tag tag;

        try {
            tag = nbt.readNamedTag().getTag();
            if (!(tag instanceof CompoundTag)) {
                throw new ChunkStoreException("CompoundTag expected for chunk; got "
                        + tag.getClass().getName());
            }

            Map<String, Tag> children = ((CompoundTag) tag).getValue();
            CompoundTag rootTag = null;

            // Find Level tag
            for (Map.Entry<String, Tag> entry : children.entrySet()) {
                if (entry.getKey().equals("Level")) {
                    if (entry.getValue() instanceof CompoundTag) {
                        rootTag = (CompoundTag) entry.getValue();
                        break;
                    } else {
                        throw new ChunkStoreException("CompoundTag expected for 'Level'; got "
                                + entry.getValue().getClass().getName());
                    }
                }
            }

            if (rootTag == null) {
                throw new ChunkStoreException("Missing root 'Level' tag");
            }

            return rootTag;
        } finally {
            nbt.close();
        }
    }
View Full Code Here

Examples of com.sk89q.jnbt.NBTInputStream

    protected MCEditSchematicFormat() {
        super("MCEdit", "mcedit", "mce");
    }

    public CuboidClipboard load(InputStream stream) throws IOException, DataException {
        NBTInputStream nbtStream = new NBTInputStream(
                new GZIPInputStream(stream));

        Vector origin = new Vector();
        Vector offset = new Vector();

        // Schematic tag
        NamedTag rootTag = nbtStream.readNamedTag();
        nbtStream.close();
        if (!rootTag.getName().equals("Schematic")) {
            throw new DataException("Tag \"Schematic\" does not exist or is not first");
        }

        CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
View Full Code Here

Examples of net.glowstone.util.nbt.NBTInputStream

        if (buf.readByte() == 0) {
            return null;
        }

        buf.readerIndex(idx);
        try (NBTInputStream str = new NBTInputStream(new ByteBufInputStream(buf), false)) {
            return str.readCompound();
        } catch (IOException e) {
            return null;
        }
    }
View Full Code Here

Examples of net.glowstone.util.nbt.NBTInputStream

        }

        DataInputStream in = region.getChunkDataInputStream(regionX, regionZ);

        CompoundTag levelTag;
        try (NBTInputStream nbt = new NBTInputStream(in, false)) {
            CompoundTag root = nbt.readCompound();
            levelTag = root.getCompound("Level");
        }

        // read the vertical sections
        List<CompoundTag> sectionList = levelTag.getCompoundList("Sections");
View Full Code Here

Examples of net.glowstone.util.nbt.NBTInputStream

        // read in world information
        CompoundTag level = new CompoundTag();
        File levelFile = new File(dir, "level.dat");
        if (levelFile.exists()) {
            try (NBTInputStream in = new NBTInputStream(new FileInputStream(levelFile))) {
                level = in.readCompound();
                if (level.isCompound("Data")) {
                    level = level.getCompound("Data");
                } else {
                    server.getLogger().warning("Loading world \"" + world.getName() + "\": reading from root, not Data");
                }
View Full Code Here

Examples of net.glowstone.util.nbt.NBTInputStream

    @Override
    public void readData(GlowPlayer player) {
        File playerFile = getPlayerFile(player.getUniqueId());
        CompoundTag playerTag = new CompoundTag();
        if (playerFile.exists()) {
            try (NBTInputStream in = new NBTInputStream(new FileInputStream(playerFile))) {
                playerTag = in.readCompound();
            } catch (IOException e) {
                player.kickPlayer("Failed to read player data!");
                server.getLogger().log(Level.SEVERE, "Failed to read data for " + player.getName() + ": " + playerFile, e);
            }
        }
View Full Code Here

Examples of net.glowstone.util.nbt.NBTInputStream

        private CompoundTag tag = new CompoundTag();
        private boolean hasPlayed = false;

        public NbtPlayerReader(File playerFile) {
            if (playerFile.exists()) {
                try (NBTInputStream in = new NBTInputStream(new FileInputStream(playerFile))) {
                    tag = in.readCompound();
                    hasPlayed = true;
                } catch (IOException e) {
                    server.getLogger().log(Level.SEVERE, "Failed to read data for player: " + playerFile, e);
                }
            }
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.