diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java index 66cd3fd33..9c62e7f6d 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java @@ -72,8 +72,8 @@ public class ChestBlock extends ContainerBlock { @Override public CompoundTag getNbtData() { Map values = new HashMap(); - values.put("Items", new ListTag("Items", CompoundTag.class, serializeInventory(getItems()))); - return new CompoundTag(getNbtId(), values); + values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems()))); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java index c52f572ff..05709cd0b 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java @@ -74,21 +74,21 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc public Map serializeItem(BaseItemStack item) { Map data = new HashMap(); - data.put("id", new ShortTag("id", (short) item.getType())); - data.put("Damage", new ShortTag("Damage", item.getData())); - data.put("Count", new ByteTag("Count", (byte) item.getAmount())); + data.put("id", new ShortTag((short) item.getType())); + data.put("Damage", new ShortTag(item.getData())); + data.put("Count", new ByteTag((byte) item.getAmount())); if (!item.getEnchantments().isEmpty()) { List enchantmentList = new ArrayList(); for(Map.Entry entry : item.getEnchantments().entrySet()) { Map enchantment = new HashMap(); - enchantment.put("id", new ShortTag("id", entry.getKey().shortValue())); - enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue())); - enchantmentList.add(new CompoundTag(null, enchantment)); + enchantment.put("id", new ShortTag(entry.getKey().shortValue())); + enchantment.put("lvl", new ShortTag(entry.getValue().shortValue())); + enchantmentList.add(new CompoundTag(enchantment)); } Map auxData = new HashMap(); - auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList)); - data.put("tag", new CompoundTag("tag", auxData)); + auxData.put("ench", new ListTag(CompoundTag.class, enchantmentList)); + data.put("tag", new CompoundTag(auxData)); } return data; } @@ -131,8 +131,8 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc for (int i = 0; i < items.length; ++i) { if (items[i] != null) { Map tagData = serializeItem(items[i]); - tagData.put("Slot", new ByteTag("Slot", (byte) i)); - tags.add(new CompoundTag("", tagData)); + tagData.put("Slot", new ByteTag((byte) i)); + tags.add(new CompoundTag(tagData)); } } return tags; diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java index 1101366b9..4140ee88a 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java @@ -71,9 +71,8 @@ public class DispenserBlock extends ContainerBlock { @Override public CompoundTag getNbtData() { Map values = new HashMap(); - values.put("Items", new ListTag("Items", CompoundTag.class, - serializeInventory(getItems()))); - return new CompoundTag(getNbtId(), values); + values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems()))); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java index 8d43f9aa7..f2001d754 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java @@ -115,11 +115,10 @@ public class FurnaceBlock extends ContainerBlock { @Override public CompoundTag getNbtData() { Map values = new HashMap(); - values.put("Items", new ListTag("Items", CompoundTag.class, - serializeInventory(getItems()))); - values.put("BurnTime", new ShortTag("BurnTime", burnTime)); - values.put("CookTime", new ShortTag("CookTime", cookTime)); - return new CompoundTag(getNbtId(), values); + values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems()))); + values.put("BurnTime", new ShortTag(burnTime)); + values.put("CookTime", new ShortTag(cookTime)); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java index 2c5a4a6b6..a876a1c1f 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java @@ -136,22 +136,22 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { @Override public CompoundTag getNbtData() { Map values = new HashMap(); - values.put("EntityId", new StringTag("EntityId", mobType)); - values.put("Delay", new ShortTag("Delay", delay)); - values.put("SpawnCount", new ShortTag("SpawnCount", spawnCount)); - values.put("SpawnRange", new ShortTag("SpawnRange", spawnRange)); - values.put("MinSpawnDelay", new ShortTag("MinSpawnDelay", minSpawnDelay)); - values.put("MaxSpawnDelay", new ShortTag("MaxSpawnDelay", maxSpawnDelay)); - values.put("MaxNearbyEntities", new ShortTag("MaxNearbyEntities", maxNearbyEntities)); - values.put("RequiredPlayerRange", new ShortTag("RequiredPlayerRange", requiredPlayerRange)); + values.put("EntityId", new StringTag(mobType)); + values.put("Delay", new ShortTag(delay)); + values.put("SpawnCount", new ShortTag(spawnCount)); + values.put("SpawnRange", new ShortTag(spawnRange)); + values.put("MinSpawnDelay", new ShortTag(minSpawnDelay)); + values.put("MaxSpawnDelay", new ShortTag(maxSpawnDelay)); + values.put("MaxNearbyEntities", new ShortTag(maxNearbyEntities)); + values.put("RequiredPlayerRange", new ShortTag(requiredPlayerRange)); if (spawnData != null) { - values.put("SpawnData", new CompoundTag("SpawnData", spawnData.getValue())); + values.put("SpawnData", new CompoundTag(spawnData.getValue())); } if (spawnPotentials != null) { - values.put("SpawnPotentials", new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentials.getValue())); + values.put("SpawnPotentials", new ListTag(CompoundTag.class, spawnPotentials.getValue())); } - return new CompoundTag(getNbtId(), values); + return new CompoundTag(values); } @Override @@ -240,10 +240,10 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { this.requiredPlayerRange = requiredPlayerRangeTag.getValue(); } if (spawnPotentialsTag != null) { - this.spawnPotentials = new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentialsTag.getValue()); + this.spawnPotentials = new ListTag(CompoundTag.class, spawnPotentialsTag.getValue()); } if (spawnDataTag != null) { - this.spawnData = new CompoundTag("SpawnData", spawnDataTag.getValue()); + this.spawnData = new CompoundTag(spawnDataTag.getValue()); } } diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java index ee479d4f3..f061723c1 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java @@ -94,8 +94,8 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock { @Override public CompoundTag getNbtData() { Map values = new HashMap(); - values.put("note", new ByteTag("note", note)); - return new CompoundTag(getNbtId(), values); + values.put("note", new ByteTag(note)); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java index 9801aebff..a0c1d303b 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java @@ -93,11 +93,11 @@ public class SignBlock extends BaseBlock implements TileEntityBlock { @Override public CompoundTag getNbtData() { Map values = new HashMap(); - values.put("Text1", new StringTag("Text1", text[0])); - values.put("Text2", new StringTag("Text2", text[1])); - values.put("Text3", new StringTag("Text3", text[2])); - values.put("Text4", new StringTag("Text4", text[3])); - return new CompoundTag(getNbtId(), values); + values.put("Text1", new StringTag(text[0])); + values.put("Text2", new StringTag(text[1])); + values.put("Text3", new StringTag(text[2])); + values.put("Text4", new StringTag(text[3])); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java index ac62da26c..d440ee0f7 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java @@ -156,11 +156,11 @@ public class SkullBlock extends BaseBlock implements TileEntityBlock { @Override public CompoundTag getNbtData() { Map values = new HashMap(); - values.put("SkullType", new ByteTag("SkullType", skullType)); + values.put("SkullType", new ByteTag(skullType)); if (owner == null) owner = ""; - values.put("ExtraType", new StringTag("ExtraType", owner)); - values.put("Rot", new ByteTag("Rot", rot)); - return new CompoundTag(getNbtId(), values); + values.put("ExtraType", new StringTag( owner)); + values.put("Rot", new ByteTag(rot)); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java index 59e7568e4..b4fb9dc52 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteArrayTag.java @@ -36,17 +36,6 @@ public final class ByteArrayTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public ByteArrayTag(String name, byte[] value) { - super(name); - this.value = value; - } - @Override public byte[] getValue() { return value; @@ -62,12 +51,7 @@ public final class ByteArrayTag extends Tag { } hex.append(hexDigits).append(" "); } - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Byte_Array" + append + ": " + hex; + return "TAG_Byte_Array(" + hex + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java index 56b6d4857..7f8f68a51 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ByteTag.java @@ -36,17 +36,6 @@ public final class ByteTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public ByteTag(String name, byte value) { - super(name); - this.value = value; - } - @Override public Byte getValue() { return value; @@ -54,12 +43,7 @@ public final class ByteTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Byte" + append + ": " + value; + return "TAG_Byte(" + value + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java index 4ab326d5e..6477d2502 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java @@ -41,17 +41,6 @@ public final class CompoundTag extends Tag { this.value = Collections.unmodifiableMap(value); } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public CompoundTag(String name, Map value) { - super(name); - this.value = Collections.unmodifiableMap(value); - } - /** * Returns whether this compound tag contains the given key. * @@ -74,7 +63,7 @@ public final class CompoundTag extends Tag { * @return the new compound tag */ public CompoundTag setValue(Map value) { - return new CompoundTag(getName(), value); + return new CompoundTag(value); } /** @@ -296,7 +285,7 @@ public final class CompoundTag extends Tag { if (tag instanceof ListTag) { return (ListTag) tag; } else { - return new ListTag(key, StringTag.class, Collections.emptyList()); + return new ListTag(StringTag.class, Collections.emptyList()); } } @@ -419,13 +408,8 @@ public final class CompoundTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_Compound").append(append).append(": ").append(value.size()).append(" entries\r\n{\r\n"); + bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n"); for (Map.Entry entry : value.entrySet()) { bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java index 187995a6b..3d476fa40 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java @@ -71,7 +71,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putByteArray(String key, byte[] value) { - return put(key, new ByteArrayTag(key, value)); + return put(key, new ByteArrayTag(value)); } /** @@ -83,7 +83,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putByte(String key, byte value) { - return put(key, new ByteTag(key, value)); + return put(key, new ByteTag(value)); } /** @@ -95,7 +95,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putDouble(String key, double value) { - return put(key, new DoubleTag(key, value)); + return put(key, new DoubleTag(value)); } /** @@ -107,7 +107,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putFloat(String key, float value) { - return put(key, new FloatTag(key, value)); + return put(key, new FloatTag(value)); } /** @@ -119,7 +119,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putIntArray(String key, int[] value) { - return put(key, new IntArrayTag(key, value)); + return put(key, new IntArrayTag(value)); } /** @@ -130,7 +130,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putInt(String key, int value) { - return put(key, new IntTag(key, value)); + return put(key, new IntTag(value)); } /** @@ -142,7 +142,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putLong(String key, long value) { - return put(key, new LongTag(key, value)); + return put(key, new LongTag(value)); } /** @@ -154,7 +154,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putShort(String key, short value) { - return put(key, new ShortTag(key, value)); + return put(key, new ShortTag(value)); } /** @@ -166,7 +166,7 @@ public class CompoundTagBuilder { * @return this object */ public CompoundTagBuilder putString(String key, String value) { - return put(key, new StringTag(key, value)); + return put(key, new StringTag(value)); } /** @@ -192,16 +192,6 @@ public class CompoundTagBuilder { return new CompoundTag(new HashMap(entries)); } - /** - * Build a new compound tag with this builder's entries. - * - * @param name the name of the tag - * @return the created compound tag - */ - public CompoundTag build(String name) { - return new CompoundTag(name, new HashMap(entries)); - } - /** * Create a new builder instance. * diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java index 1ebcdf794..8f8e3b594 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java @@ -37,17 +37,6 @@ public final class DoubleTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public DoubleTag(String name, double value) { - super(name); - this.value = value; - } - @Override public Double getValue() { return value; @@ -55,12 +44,7 @@ public final class DoubleTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Double" + append + ": " + value; + return "TAG_Double(" + value + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java index 1db29b3d6..e5dd2279a 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/EndTag.java @@ -24,13 +24,6 @@ package com.sk89q.jnbt; */ public final class EndTag extends Tag { - /** - * Creates the tag. - */ - public EndTag() { - super(); - } - @Override public Object getValue() { return null; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java index 21b921b69..273da606c 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/FloatTag.java @@ -36,17 +36,6 @@ public final class FloatTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public FloatTag(String name, float value) { - super(name); - this.value = value; - } - @Override public Float getValue() { return value; @@ -54,12 +43,7 @@ public final class FloatTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Float" + append + ": " + value; + return "TAG_Float(" + value + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java index 58b318c79..7c5e49603 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java @@ -39,18 +39,6 @@ public final class IntArrayTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public IntArrayTag(String name, int[] value) { - super(name); - checkNotNull(value); - this.value = value; - } - @Override public int[] getValue() { return value; @@ -66,12 +54,7 @@ public final class IntArrayTag extends Tag { } hex.append(hexDigits).append(" "); } - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Int_Array" + append + ": " + hex; + return "TAG_Int_Array(" + hex + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java index 5591408f6..944c736d6 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/IntTag.java @@ -36,17 +36,6 @@ public final class IntTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public IntTag(String name, int value) { - super(name); - this.value = value; - } - @Override public Integer getValue() { return value; @@ -54,12 +43,7 @@ public final class IntTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Int" + append + ": " + value; + return "TAG_Int(" + value + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java index 28b004588..3cbe42977 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java @@ -47,20 +47,6 @@ public final class ListTag extends Tag { this.value = Collections.unmodifiableList(value); } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param type the type of tag - * @param value the value of the tag - */ - public ListTag(String name, Class type, List value) { - super(name); - checkNotNull(value); - this.type = type; - this.value = Collections.unmodifiableList(value); - } - /** * Gets the type of item in this list. * @@ -82,7 +68,7 @@ public final class ListTag extends Tag { * @return a new list tag */ public ListTag setValue(List list) { - return new ListTag(getName(), getType(), list); + return new ListTag(getType(), list); } /** @@ -433,13 +419,8 @@ public final class ListTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n"); + bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n"); for (Tag t : value) { bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java index 2934c2255..9bcbbfd05 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java @@ -83,16 +83,6 @@ public class ListTagBuilder { return new ListTag(type, new ArrayList(entries)); } - /** - * Build a new list tag with this builder's entries. - * - * @param name the name of the tag - * @return the created list tag - */ - public ListTag build(String name) { - return new ListTag(name, type, new ArrayList(entries)); - } - /** * Create a new builder instance. * diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java index 26e1902a5..a28ad1f64 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java @@ -37,17 +37,6 @@ public final class LongTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public LongTag(String name, long value) { - super(name); - this.value = value; - } - @Override public Long getValue() { return value; @@ -55,12 +44,7 @@ public final class LongTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Long" + append + ": " + value; + return "TAG_Long(" + value + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java index 31fab63a1..223ca2248 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java @@ -58,8 +58,8 @@ public final class NBTInputStream implements Closeable { * @return The tag that was read. * @throws IOException if an I/O error occurs. */ - public Tag readTag() throws IOException { - return readTag(0); + public NamedTag readNamedTag() throws IOException { + return readNamedTag(0); } /** @@ -69,7 +69,7 @@ public final class NBTInputStream implements Closeable { * @return The tag that was read. * @throws IOException if an I/O error occurs. */ - private Tag readTag(int depth) throws IOException { + private NamedTag readNamedTag(int depth) throws IOException { int type = is.readByte() & 0xFF; String name; @@ -82,19 +82,18 @@ public final class NBTInputStream implements Closeable { name = ""; } - return readTagPayload(type, name, depth); + return new NamedTag(name, readTagPayload(type, depth)); } /** - * Reads the payload of a tag, given the name and type. + * Reads the payload of a tag given the type. * * @param type the type - * @param name the name * @param depth the depth * @return the tag * @throws IOException if an I/O error occurs. */ - private Tag readTagPayload(int type, String name, int depth) throws IOException { + private Tag readTagPayload(int type, int depth) throws IOException { switch (type) { case NBTConstants.TYPE_END: if (depth == 0) { @@ -104,60 +103,61 @@ public final class NBTInputStream implements Closeable { return new EndTag(); } case NBTConstants.TYPE_BYTE: - return new ByteTag(name, is.readByte()); + return new ByteTag(is.readByte()); case NBTConstants.TYPE_SHORT: - return new ShortTag(name, is.readShort()); + return new ShortTag(is.readShort()); case NBTConstants.TYPE_INT: - return new IntTag(name, is.readInt()); + return new IntTag(is.readInt()); case NBTConstants.TYPE_LONG: - return new LongTag(name, is.readLong()); + return new LongTag(is.readLong()); case NBTConstants.TYPE_FLOAT: - return new FloatTag(name, is.readFloat()); + return new FloatTag(is.readFloat()); case NBTConstants.TYPE_DOUBLE: - return new DoubleTag(name, is.readDouble()); + return new DoubleTag(is.readDouble()); case NBTConstants.TYPE_BYTE_ARRAY: int length = is.readInt(); byte[] bytes = new byte[length]; is.readFully(bytes); - return new ByteArrayTag(name, bytes); + return new ByteArrayTag(bytes); case NBTConstants.TYPE_STRING: length = is.readShort(); bytes = new byte[length]; is.readFully(bytes); - return new StringTag(name, new String(bytes, NBTConstants.CHARSET)); + return new StringTag(new String(bytes, NBTConstants.CHARSET)); case NBTConstants.TYPE_LIST: int childType = is.readByte(); length = is.readInt(); List tagList = new ArrayList(); for (int i = 0; i < length; ++i) { - Tag tag = readTagPayload(childType, "", depth + 1); + Tag tag = readTagPayload(childType, depth + 1); if (tag instanceof EndTag) { throw new IOException("TAG_End not permitted in a list."); } tagList.add(tag); } - return new ListTag(name, NBTUtils.getTypeClass(childType), tagList); + return new ListTag(NBTUtils.getTypeClass(childType), tagList); case NBTConstants.TYPE_COMPOUND: Map tagMap = new HashMap(); while (true) { - Tag tag = readTag(depth + 1); + NamedTag namedTag = readNamedTag(depth + 1); + Tag tag = namedTag.getTag(); if (tag instanceof EndTag) { break; } else { - tagMap.put(tag.getName(), tag); + tagMap.put(namedTag.getName(), tag); } } - return new CompoundTag(name, tagMap); + return new CompoundTag(tagMap); case NBTConstants.TYPE_INT_ARRAY: length = is.readInt(); int[] data = new int[length]; for (int i = 0; i < length; i++) { data[i] = is.readInt(); } - return new IntArrayTag(name, data); + return new IntArrayTag(data); default: throw new IOException("Invalid tag type: " + type + "."); } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java index eabc87d28..a54ea6e26 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java @@ -24,6 +24,9 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.List; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; /** * This class writes NBT, or Named Binary Tag @@ -61,9 +64,11 @@ public final class NBTOutputStream implements Closeable { * @throws IOException * if an I/O error occurs. */ - public void writeTag(Tag tag) throws IOException { + public void writeNamedTag(String name, Tag tag) throws IOException { + checkNotNull(name); + checkNotNull(tag); + int type = NBTUtils.getTypeCode(tag.getClass()); - String name = tag.getName(); byte[] nameBytes = name.getBytes(NBTConstants.CHARSET); os.writeByte(type); @@ -164,8 +169,8 @@ public final class NBTOutputStream implements Closeable { * if an I/O error occurs. */ private void writeCompoundTagPayload(CompoundTag tag) throws IOException { - for (Tag childTag : tag.getValue().values()) { - writeTag(childTag); + for (Map.Entry entry : tag.getValue().entrySet()) { + writeNamedTag(entry.getKey(), entry.getValue()); } os.writeByte((byte) 0); // end tag - better way? } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NamedTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NamedTag.java new file mode 100644 index 000000000..37ecec278 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NamedTag.java @@ -0,0 +1,63 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.jnbt; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * A tag that has a name. + */ +public class NamedTag { + + private final String name; + private final Tag tag; + + /** + * Create a new named tag. + * + * @param name the name + * @param tag the tag + */ + public NamedTag(String name, Tag tag) { + checkNotNull(name); + checkNotNull(tag); + this.name = name; + this.tag = tag; + } + + /** + * Get the name of the tag. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Get the tag. + * + * @return the tag + */ + public Tag getTag() { + return tag; + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java index fd3ee3a4e..a2f4d397b 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ShortTag.java @@ -36,17 +36,6 @@ public final class ShortTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public ShortTag(String name, short value) { - super(name); - this.value = value; - } - @Override public Short getValue() { return value; @@ -54,12 +43,7 @@ public final class ShortTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_Short" + append + ": " + value; + return "TAG_Short(" + value + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java index 409511ab5..5a2c504a8 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/StringTag.java @@ -39,18 +39,6 @@ public final class StringTag extends Tag { this.value = value; } - /** - * Creates the tag. - * - * @param name the name of the tag - * @param value the value of the tag - */ - public StringTag(String name, String value) { - super(name); - checkNotNull(value); - this.value = value; - } - @Override public String getValue() { return value; @@ -58,12 +46,7 @@ public final class StringTag extends Tag { @Override public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - return "TAG_String" + append + ": " + value; + return "TAG_String(" + value + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java index e0d7d3f4b..622a80705 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/Tag.java @@ -24,36 +24,6 @@ package com.sk89q.jnbt; */ public abstract class Tag { - private final String name; - - /** - * Create a new tag with an empty name. - */ - Tag() { - this(""); - } - - /** - * Creates the tag with the specified name. - * - * @param name the name - */ - Tag(String name) { - if (name == null) { - name = ""; - } - this.name = name; - } - - /** - * Gets the name of this tag. - * - * @return the name of this tag - */ - public final String getName() { - return name; - } - /** * Gets the value of this tag. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java index c6a17cb88..771d850cf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java @@ -24,6 +24,7 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.NBTInputStream; +import com.sk89q.jnbt.NamedTag; import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; @@ -71,10 +72,11 @@ public class SchematicReader implements ClipboardReader { @Override public Clipboard read(WorldData data) throws IOException { // Schematic tag - CompoundTag schematicTag = (CompoundTag) inputStream.readTag(); - if (!schematicTag.getName().equals("Schematic")) { + NamedTag rootTag = inputStream.readNamedTag(); + if (!rootTag.getName().equals("Schematic")) { throw new IOException("Tag 'Schematic' does not exist or is not first"); } + CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); // Check Map schematic = schematicTag.getValue(); @@ -197,7 +199,7 @@ public class SchematicReader implements ClipboardReader { BaseBlock block = new BaseBlock(blocks[index], blockData[index]); if (tileEntitiesMap.containsKey(pt)) { - block.setNbtData(new CompoundTag("", tileEntitiesMap.get(pt))); + block.setNbtData(new CompoundTag(tileEntitiesMap.get(pt))); } try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java index 6e907cb0e..b3546e4d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java @@ -90,16 +90,16 @@ public class SchematicWriter implements ClipboardWriter { // ==================================================================== HashMap schematic = new HashMap(); - schematic.put("Width", new ShortTag("Width", (short) width)); - schematic.put("Length", new ShortTag("Length", (short) length)); - schematic.put("Height", new ShortTag("Height", (short) height)); - schematic.put("Materials", new StringTag("Materials", "Alpha")); - schematic.put("WEOriginX", new IntTag("WEOriginX", min.getBlockX())); - schematic.put("WEOriginY", new IntTag("WEOriginY", min.getBlockY())); - schematic.put("WEOriginZ", new IntTag("WEOriginZ", min.getBlockZ())); - schematic.put("WEOffsetX", new IntTag("WEOffsetX", offset.getBlockX())); - schematic.put("WEOffsetY", new IntTag("WEOffsetY", offset.getBlockY())); - schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", offset.getBlockZ())); + schematic.put("Width", new ShortTag((short) width)); + schematic.put("Length", new ShortTag((short) length)); + schematic.put("Height", new ShortTag((short) height)); + schematic.put("Materials", new StringTag("Alpha")); + schematic.put("WEOriginX", new IntTag(min.getBlockX())); + schematic.put("WEOriginY", new IntTag(min.getBlockY())); + schematic.put("WEOriginZ", new IntTag(min.getBlockZ())); + schematic.put("WEOffsetX", new IntTag(offset.getBlockX())); + schematic.put("WEOffsetY", new IntTag(offset.getBlockY())); + schematic.put("WEOffsetZ", new IntTag(offset.getBlockZ())); // ==================================================================== // Block handling @@ -141,22 +141,22 @@ public class SchematicWriter implements ClipboardWriter { values.put(entry.getKey(), entry.getValue()); } - values.put("id", new StringTag("id", block.getNbtId())); - values.put("x", new IntTag("x", x)); - values.put("y", new IntTag("y", y)); - values.put("z", new IntTag("z", z)); + values.put("id", new StringTag(block.getNbtId())); + values.put("x", new IntTag(x)); + values.put("y", new IntTag(y)); + values.put("z", new IntTag(z)); - CompoundTag tileEntityTag = new CompoundTag("TileEntity", values); + CompoundTag tileEntityTag = new CompoundTag(values); tileEntities.add(tileEntityTag); } } - schematic.put("Blocks", new ByteArrayTag("Blocks", blocks)); - schematic.put("Data", new ByteArrayTag("Data", blockData)); - schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities)); + schematic.put("Blocks", new ByteArrayTag(blocks)); + schematic.put("Data", new ByteArrayTag(blockData)); + schematic.put("TileEntities", new ListTag(CompoundTag.class, tileEntities)); if (addBlocks != null) { - schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks)); + schematic.put("AddBlocks", new ByteArrayTag(addBlocks)); } // ==================================================================== @@ -177,38 +177,38 @@ public class SchematicWriter implements ClipboardWriter { } // Store our location data, overwriting any - values.put("id", new StringTag("id", state.getTypeId())); + values.put("id", new StringTag(state.getTypeId())); values.put("Pos", writeVector(entity.getLocation().toVector(), "Pos")); values.put("Rotation", writeRotation(entity.getLocation(), "Rotation")); - CompoundTag entityTag = new CompoundTag("Entity", values); + CompoundTag entityTag = new CompoundTag(values); entities.add(entityTag); } } - schematic.put("Entities", new ListTag("Entities", CompoundTag.class, entities)); + schematic.put("Entities", new ListTag(CompoundTag.class, entities)); // ==================================================================== // Output // ==================================================================== - CompoundTag schematicTag = new CompoundTag("Schematic", schematic); - outputStream.writeTag(schematicTag); + CompoundTag schematicTag = new CompoundTag(schematic); + outputStream.writeNamedTag("Schematic", schematicTag); } private Tag writeVector(Vector vector, String name) { List list = new ArrayList(); - list.add(new DoubleTag("", vector.getX())); - list.add(new DoubleTag("", vector.getY())); - list.add(new DoubleTag("", vector.getZ())); - return new ListTag(name, DoubleTag.class, list); + list.add(new DoubleTag(vector.getX())); + list.add(new DoubleTag(vector.getY())); + list.add(new DoubleTag(vector.getZ())); + return new ListTag(DoubleTag.class, list); } private Tag writeRotation(Location location, String name) { List list = new ArrayList(); - list.add(new FloatTag("", location.getYaw())); - list.add(new FloatTag("", location.getPitch())); - return new ListTag(name, FloatTag.class, list); + list.add(new FloatTag(location.getYaw())); + list.add(new FloatTag(location.getPitch())); + return new ListTag(FloatTag.class, list); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java index 118681eb6..10afbb826 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java @@ -19,15 +19,29 @@ package com.sk89q.worldedit.schematic; -import com.sk89q.jnbt.*; +import com.sk89q.jnbt.ByteArrayTag; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.IntTag; +import com.sk89q.jnbt.ListTag; +import com.sk89q.jnbt.NBTConstants; +import com.sk89q.jnbt.NBTInputStream; +import com.sk89q.jnbt.NBTOutputStream; +import com.sk89q.jnbt.NamedTag; +import com.sk89q.jnbt.ShortTag; +import com.sk89q.jnbt.StringTag; +import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.CuboidClipboard; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.data.DataException; -import java.io.*; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -52,12 +66,14 @@ public class MCEditSchematicFormat extends SchematicFormat { Vector offset = new Vector(); // Schematic tag - CompoundTag schematicTag = (CompoundTag) nbtStream.readTag(); + NamedTag rootTag = nbtStream.readNamedTag(); nbtStream.close(); - if (!schematicTag.getName().equals("Schematic")) { + if (!rootTag.getName().equals("Schematic")) { throw new DataException("Tag \"Schematic\" does not exist or is not first"); } + CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); + // Check Map schematic = schematicTag.getValue(); if (!schematic.containsKey("Blocks")) { @@ -169,7 +185,7 @@ public class MCEditSchematicFormat extends SchematicFormat { BaseBlock block = getBlockForId(blocks[index], blockData[index]); if (tileEntitiesMap.containsKey(pt)) { - block.setNbtData(new CompoundTag("", tileEntitiesMap.get(pt))); + block.setNbtData(new CompoundTag(tileEntitiesMap.get(pt))); } clipboard.setBlock(pt, block); } @@ -201,16 +217,16 @@ public class MCEditSchematicFormat extends SchematicFormat { } HashMap schematic = new HashMap(); - schematic.put("Width", new ShortTag("Width", (short) width)); - schematic.put("Length", new ShortTag("Length", (short) length)); - schematic.put("Height", new ShortTag("Height", (short) height)); - schematic.put("Materials", new StringTag("Materials", "Alpha")); - schematic.put("WEOriginX", new IntTag("WEOriginX", clipboard.getOrigin().getBlockX())); - schematic.put("WEOriginY", new IntTag("WEOriginY", clipboard.getOrigin().getBlockY())); - schematic.put("WEOriginZ", new IntTag("WEOriginZ", clipboard.getOrigin().getBlockZ())); - schematic.put("WEOffsetX", new IntTag("WEOffsetX", clipboard.getOffset().getBlockX())); - schematic.put("WEOffsetY", new IntTag("WEOffsetY", clipboard.getOffset().getBlockY())); - schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", clipboard.getOffset().getBlockZ())); + schematic.put("Width", new ShortTag((short) width)); + schematic.put("Length", new ShortTag((short) length)); + schematic.put("Height", new ShortTag((short) height)); + schematic.put("Materials", new StringTag("Alpha")); + schematic.put("WEOriginX", new IntTag(clipboard.getOrigin().getBlockX())); + schematic.put("WEOriginY", new IntTag(clipboard.getOrigin().getBlockY())); + schematic.put("WEOriginZ", new IntTag(clipboard.getOrigin().getBlockZ())); + schematic.put("WEOffsetX", new IntTag(clipboard.getOffset().getBlockX())); + schematic.put("WEOffsetY", new IntTag(clipboard.getOffset().getBlockY())); + schematic.put("WEOffsetZ", new IntTag(clipboard.getOffset().getBlockZ())); // Copy byte[] blocks = new byte[width * height * length]; @@ -246,30 +262,30 @@ public class MCEditSchematicFormat extends SchematicFormat { values.put(entry.getKey(), entry.getValue()); } - values.put("id", new StringTag("id", block.getNbtId())); - values.put("x", new IntTag("x", x)); - values.put("y", new IntTag("y", y)); - values.put("z", new IntTag("z", z)); + values.put("id", new StringTag(block.getNbtId())); + values.put("x", new IntTag(x)); + values.put("y", new IntTag(y)); + values.put("z", new IntTag(z)); - CompoundTag tileEntityTag = new CompoundTag("TileEntity", values); + CompoundTag tileEntityTag = new CompoundTag(values); tileEntities.add(tileEntityTag); } } } } - schematic.put("Blocks", new ByteArrayTag("Blocks", blocks)); - schematic.put("Data", new ByteArrayTag("Data", blockData)); - schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList())); - schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities)); + schematic.put("Blocks", new ByteArrayTag(blocks)); + schematic.put("Data", new ByteArrayTag(blockData)); + schematic.put("Entities", new ListTag(CompoundTag.class, new ArrayList())); + schematic.put("TileEntities", new ListTag(CompoundTag.class, tileEntities)); if (addBlocks != null) { - schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks)); + schematic.put("AddBlocks", new ByteArrayTag(addBlocks)); } // Build and output - CompoundTag schematicTag = new CompoundTag("Schematic", schematic); + CompoundTag schematicTag = new CompoundTag(schematic); NBTOutputStream stream = new NBTOutputStream(new GZIPOutputStream(new FileOutputStream(file))); - stream.writeTag(schematicTag); + stream.writeNamedTag("Schematic", schematicTag); stream.close(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 15a93f575..f52f6d969 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -255,7 +255,7 @@ public class AnvilChunk implements Chunk { return null; } - return new CompoundTag("", values); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java index d92bb1bda..98849cdcb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java @@ -179,7 +179,7 @@ public class OldChunk implements Chunk { if (values == null) { return null; } - return new CompoundTag("", values); + return new CompoundTag(values); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java index 1a2eb46c9..b46467ea4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java @@ -85,7 +85,7 @@ public abstract class LegacyChunkStore extends ChunkStore { Tag tag; try { - tag = nbt.readTag(); + tag = nbt.readNamedTag().getTag(); if (!(tag instanceof CompoundTag)) { throw new ChunkStoreException("CompoundTag expected for chunk; got " + tag.getClass().getName()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java index fd564752a..f7c5fd691 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java @@ -75,7 +75,7 @@ public abstract class McRegionChunkStore extends ChunkStore { Tag tag; try { - tag = nbt.readTag(); + tag = nbt.readNamedTag().getTag(); if (!(tag instanceof CompoundTag)) { throw new ChunkStoreException("CompoundTag expected for chunk; got " + tag.getClass().getName()); }