当前位置: 首页>>代码示例>>Java>>正文


Java Tag类代码示例

本文整理汇总了Java中com.intellectualcrafters.jnbt.Tag的典型用法代码示例。如果您正苦于以下问题:Java Tag类的具体用法?Java Tag怎么用?Java Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Tag类属于com.intellectualcrafters.jnbt包,在下文中一共展示了Tag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCompoundTag

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
@Override
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
    TaskManager.IMP.async(new Runnable() {
        @Override
        public void run() {
            Location[] corners = MainUtil.getCorners(world, regions);
            Location pos1 = corners[0];
            Location pos2 = corners[1];
            final CuboidRegion region = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
            final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();

            final int mx = pos1.getX();
            final int my = pos1.getY();
            final int mz = pos1.getZ();

            ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region);

            Clipboard holder = new BlockArrayClipboard(region, clipboard);
            com.sk89q.jnbt.CompoundTag weTag = SchematicWriter.writeTag(holder);
            CompoundTag tag = new CompoundTag((Map<String, Tag>) (Map<?, ?>) weTag.getValue());
            whenDone.run(tag);
        }
    });
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:25,代码来源:FaweSchematicHandler.java

示例2: upload

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
@Override
public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
    if (tag == null) {
        PS.debug("&cCannot save empty tag");
        com.intellectualcrafters.plot.util.TaskManager.runTask(whenDone);
        return;
    }
    MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
        @Override
        public void run(OutputStream output) {
            try {
                try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) {
                    com.sk89q.jnbt.CompoundTag weTag = (com.sk89q.jnbt.CompoundTag) FaweCache.asTag(tag);
                    try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
                        Map<String, com.sk89q.jnbt.Tag> map = weTag.getValue();
                        nos.writeNamedTag("Schematic", map.containsKey("Schematic") ? map.get("Schematic") : weTag);
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }, whenDone);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:25,代码来源:FaweSchematicHandler.java

示例3: serializeItem

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public Map<String, Tag> serializeItem(ItemStack item) {
    Map<String, Tag> data = new HashMap<String, Tag>();
    data.put("id", new ShortTag("id", (short) item.getTypeId()));
    data.put("Damage", new ShortTag("Damage", item.getDurability()));
    data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
    if (!item.getEnchantments().isEmpty()) {
        List<CompoundTag> enchantmentList = new ArrayList<CompoundTag>();
        for(Entry<Enchantment, Integer> entry : item.getEnchantments().entrySet()) {
            Map<String, Tag> enchantment = new HashMap<String, Tag>();
            enchantment.put("id", new ShortTag("id", (short) entry.getKey().getId()));
            enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue()));
            enchantmentList.add(new CompoundTag(enchantment));
        }
        Map<String, Tag> auxData = new HashMap<String, Tag>();
        auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList));
        data.put("tag", new CompoundTag("tag", auxData));
    }
    return data;
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:20,代码来源:StateWrapper.java

示例4: serializeItem

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public Map<String, Tag> serializeItem(ItemStack item) {
    Map<String, Tag> data = new HashMap<>();
    data.put("id", new ShortTag("id", (short) item.getTypeId()));
    data.put("Damage", new ShortTag("Damage", item.getDurability()));
    data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
    if (!item.getEnchantments().isEmpty()) {
        List<CompoundTag> enchantmentList = new ArrayList<>();
        for (Entry<Enchantment, Integer> entry : item.getEnchantments().entrySet()) {
            Map<String, Tag> enchantment = new HashMap<>();
            enchantment.put("id", new ShortTag("id", (short) entry.getKey().getId()));
            enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue()));
            enchantmentList.add(new CompoundTag(enchantment));
        }
        Map<String, Tag> auxData = new HashMap<>();
        auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList));
        data.put("tag", new CompoundTag("tag", auxData));
    }
    return data;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:20,代码来源:StateWrapper.java

示例5: createTag

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
/**
 * Create a compound tag from blocks
 *  - Untested
 * @param blocks
 * @param blockData
 * @param dimension
 * @return
 */
public CompoundTag createTag(byte[] blocks, byte[] blockData, Dimension dimension) {
    HashMap<String, Tag> schematic = new HashMap<>();
    schematic.put("Width", new ShortTag("Width", (short) dimension.getX()));
    schematic.put("Length", new ShortTag("Length", (short) dimension.getZ()));
    schematic.put("Height", new ShortTag("Height", (short) dimension.getY()));
    schematic.put("Materials", new StringTag("Materials", "Alpha"));
    schematic.put("WEOriginX", new IntTag("WEOriginX", 0));
    schematic.put("WEOriginY", new IntTag("WEOriginY", 0));
    schematic.put("WEOriginZ", new IntTag("WEOriginZ", 0));
    schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
    schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
    schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
    schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
    schematic.put("Data", new ByteArrayTag("Data", blockData));
    schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
    schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, new ArrayList<Tag>()));
    return new CompoundTag("Schematic", schematic);
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:27,代码来源:SchematicHandler.java

示例6: getCompoundTag

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public void getCompoundTag(final Plot plot, final RunnableVal<CompoundTag> whenDone) {
    getCompoundTag(plot.getWorldName(), plot.getRegions(), new RunnableVal<CompoundTag>() {
        @Override
        public void run(CompoundTag value) {
            if (!plot.getFlags().isEmpty()) {
                HashMap<String, Tag> flagMap = new HashMap<>();
                for (Map.Entry<Flag<?>, Object> entry : plot.getFlags().entrySet()) {
                    String key = entry.getKey().getName();
                    flagMap.put(key, new StringTag(key, entry.getKey().valueToString(entry.getValue())));
                }
                CompoundTag tag = new CompoundTag("Flags", flagMap);
                HashMap<String, Tag> map = new HashMap<>(value.getValue());
                map.put("Flags", tag);
                value.setValue(map);
            }
            whenDone.run(value);
        }
    });
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:20,代码来源:SchematicHandler.java

示例7: restoreTag

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public boolean restoreTag(short x, short y, short z, Schematic schematic) {
    if (this.tag == null) {
        return false;
    }
    List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
    int length = itemsTag.size();
    short[] ids = new short[length];
    byte[] datas = new byte[length];
    byte[] amounts = new byte[length];
    for (int i = 0; i < length; i++) {
        Tag itemTag = itemsTag.get(i);
        CompoundTag itemComp = (CompoundTag) itemTag;
        short id = itemComp.getShort("id");
        String idStr = itemComp.getString("id");
        if (!StringUtils.isNumeric(idStr) && idStr != null) {
            idStr = idStr.split(":")[1].toLowerCase();
            id = (short) ItemType.getId(idStr);
        }
        ids[i] = id;
        datas[i] = (byte) itemComp.getShort("Damage");
        amounts[i] = itemComp.getByte("Count");
    }
    if (length != 0) {
        schematic.addItem(new PlotItem(x, y, z, ids, datas, amounts));
    }
    return true;
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:28,代码来源:StateWrapper.java

示例8: getTag

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public CompoundTag getTag() {
    if (this.tag != null) {
        return this.tag;
    }
    if (state instanceof InventoryHolder) {
        InventoryHolder inv = (InventoryHolder) state;
        ItemStack[] contents = inv.getInventory().getContents();
        Map<String, Tag> values = new HashMap<String, Tag>();
        values.put("Items", new ListTag("Items", CompoundTag.class, serializeInventory(contents)));
        return new CompoundTag(values);
    }
    return null;
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:14,代码来源:StateWrapper.java

示例9: serializeInventory

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public List<CompoundTag> serializeInventory(ItemStack[] items) {
    List<CompoundTag> tags = new ArrayList<CompoundTag>();
    for (int i = 0; i < items.length; ++i) {
        if (items[i] != null) {
            Map<String, Tag> tagData = serializeItem(items[i]);
            tagData.put("Slot", new ByteTag("Slot", (byte) i));
            tags.add(new CompoundTag(tagData));
        }
    }
    return tags;
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:12,代码来源:StateWrapper.java

示例10: getTag

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public CompoundTag getTag() {
    if (this.tag != null) {
        return this.tag;
    }
    if (this.state instanceof InventoryHolder) {
        InventoryHolder inv = (InventoryHolder) this.state;
        ItemStack[] contents = inv.getInventory().getContents();
        Map<String, Tag> values = new HashMap<>();
        values.put("Items", new ListTag("Items", CompoundTag.class, serializeInventory(contents)));
        return new CompoundTag(values);
    }
    return null;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:14,代码来源:StateWrapper.java

示例11: serializeInventory

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public List<CompoundTag> serializeInventory(ItemStack[] items) {
    List<CompoundTag> tags = new ArrayList<>();
    for (int i = 0; i < items.length; ++i) {
        if (items[i] != null) {
            Map<String, Tag> tagData = serializeItem(items[i]);
            tagData.put("Slot", new ByteTag("Slot", (byte) i));
            tags.add(new CompoundTag(tagData));
        }
    }
    return tags;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:12,代码来源:StateWrapper.java

示例12: restoreTag

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public boolean restoreTag(String worldName, int x, int y, int z) {
    if (this.tag == null) {
        return false;
    }
    switch (this.tag.getString("id").toLowerCase()) {
        case "chest":
            List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
            int length = itemsTag.size();
            short[] ids = new short[length];
            byte[] datas = new byte[length];
            byte[] amounts = new byte[length];
            byte[] slots = new byte[length];
            for (int i = 0; i < length; i++) {
                Tag itemTag = itemsTag.get(i);
                CompoundTag itemComp = (CompoundTag) itemTag;
                short id = itemComp.getShort("id");
                String idStr = itemComp.getString("id");
                if (idStr != null && !MathMan.isInteger(idStr)) {
                    idStr = idStr.split(":")[1].toLowerCase();
                    id = (short) ItemType.getId(idStr);
                }
                ids[i] = id;
                datas[i] = (byte) itemComp.getShort("Damage");
                amounts[i] = itemComp.getByte("Count");
                slots[i] = itemComp.getByte("Slot");
            }
            World world = BukkitUtil.getWorld(worldName);
            Block block = world.getBlockAt(x, y, z);
            if (block == null) {
                return false;
            }
            BlockState state = block.getState();
            if (state instanceof InventoryHolder) {
                InventoryHolder holder = (InventoryHolder) state;
                Inventory inv = holder.getInventory();
                for (int i = 0; i < ids.length; i++) {
                    ItemStack item = new ItemStack(ids[i], amounts[i], datas[i]);
                    inv.addItem(item);
                }
                state.update(true);
                return true;
            }
    }
    return false;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:46,代码来源:StateWrapper.java

示例13: Schematic

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public Schematic(short[] i, byte[] b, Dimension d, Map<String, Tag> flags) {
    this.ids = i;
    this.datas = b;
    this.schematicDimension = d;
    setFlags(flags);
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:7,代码来源:SchematicHandler.java

示例14: getFlags

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public Map<String, Tag> getFlags() {
    return this.flags;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:4,代码来源:SchematicHandler.java

示例15: setFlags

import com.intellectualcrafters.jnbt.Tag; //导入依赖的package包/类
public void setFlags(Map<String, Tag> flags) {
    this.flags = flags == null ? new HashMap<String, Tag>() : flags;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:4,代码来源:SchematicHandler.java


注:本文中的com.intellectualcrafters.jnbt.Tag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。