diff --git a/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R1.class b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R1.class
index ccf0a882d..7c2a08996 100644
Binary files a/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R1.class and b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R1.class differ
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 8f1a7793c..2c439e11b 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java
@@ -317,6 +317,24 @@ public final class CompoundTag extends Tag {
}
}
+ /**
+ * Get a {@code long[]} named with the given key.
+ *
+ *
If the key does not exist or its value is not an long array tag,
+ * then an empty array will be returned.
+ *
+ * @param key the key
+ * @return an int array
+ */
+ public long[] getLongArray(String key) {
+ Tag tag = value.get(key);
+ if (tag instanceof LongArrayTag) {
+ return ((LongArrayTag) tag).getValue();
+ } else {
+ return new long[0];
+ }
+ }
+
/**
* Get a long named with the given key.
*
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 c6d8fe9e8..b0e873c0d 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java
@@ -133,6 +133,18 @@ public class CompoundTagBuilder {
return put(key, new IntTag(value));
}
+ /**
+ * Put the given key and value into the compound tag as a
+ * {@code LongArrayTag}.
+ *
+ * @param key they key
+ * @param value the value
+ * @return this object
+ */
+ public CompoundTagBuilder putLongArray(String key, long[] value) {
+ return put(key, new LongArrayTag(value));
+ }
+
/**
* Put the given key and value into the compound tag as a
* {@code LongTag}.
diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java
new file mode 100644
index 000000000..30dad0cc3
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+/**
+ * The {@code TAG_Long_Array} tag.
+ */
+public class LongArrayTag extends Tag {
+
+ private final long[] value;
+
+ /**
+ * Creates the tag with an empty name.
+ *
+ * @param value the value of the tag
+ */
+ public LongArrayTag(long[] value) {
+ super();
+ checkNotNull(value);
+ this.value = value;
+ }
+
+ @Override
+ public long[] getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder hex = new StringBuilder();
+ for (long b : value) {
+ String hexDigits = Long.toHexString(b).toUpperCase();
+ if (hexDigits.length() == 1) {
+ hex.append("0");
+ }
+ hex.append(hexDigits).append(" ");
+ }
+ return "TAG_Long_Array(" + hex + ")";
+ }
+
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java
index 2ff2768ac..1cbff362d 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java
@@ -31,7 +31,7 @@ public final class NBTConstants {
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2,
TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,
TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
- TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
+ TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11, TYPE_LONG_ARRAY = 12;
/**
* Default private constructor.
@@ -73,6 +73,8 @@ public final class NBTConstants {
return CompoundTag.class;
case TYPE_INT_ARRAY:
return IntArrayTag.class;
+ case TYPE_LONG_ARRAY:
+ return LongArrayTag.class;
default:
throw new IllegalArgumentException("Unknown tag type ID of " + id);
}
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 bd6a1f9f2..b6096a163 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java
@@ -158,6 +158,13 @@ public final class NBTInputStream implements Closeable {
data[i] = is.readInt();
}
return new IntArrayTag(data);
+ case NBTConstants.TYPE_LONG_ARRAY:
+ length = is.readInt();
+ long[] longData = new long[length];
+ for (int i = 0; i < length; i++) {
+ longData[i] = is.readLong();
+ }
+ return new LongArrayTag(longData);
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 ddf1168be..5bed0297f 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java
@@ -129,6 +129,9 @@ public final class NBTOutputStream implements Closeable {
case NBTConstants.TYPE_INT_ARRAY:
writeIntArrayTagPayload((IntArrayTag) tag);
break;
+ case NBTConstants.TYPE_LONG_ARRAY:
+ writeLongArrayTagPayload((LongArrayTag) tag);
+ break;
default:
throw new IOException("Invalid tag type: " + type + ".");
}
@@ -286,6 +289,14 @@ public final class NBTOutputStream implements Closeable {
}
}
+ private void writeLongArrayTagPayload(LongArrayTag tag) throws IOException {
+ long[] data = tag.getValue();
+ os.writeInt(data.length);
+ for (long aData : data) {
+ os.writeLong(aData);
+ }
+ }
+
@Override
public void close() throws IOException {
os.close();
diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java
index 440738c4e..e44262911 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java
@@ -69,6 +69,8 @@ public final class NBTUtils {
return "TAG_String";
} else if (clazz.equals(IntArrayTag.class)) {
return "TAG_Int_Array";
+ } else if (clazz.equals(LongArrayTag.class)) {
+ return "TAG_Long_Array";
} else {
throw new IllegalArgumentException("Invalid tag classs ("
+ clazz.getName() + ").");
@@ -107,6 +109,8 @@ public final class NBTUtils {
return NBTConstants.TYPE_STRING;
} else if (clazz.equals(IntArrayTag.class)) {
return NBTConstants.TYPE_INT_ARRAY;
+ } else if (clazz.equals(LongArrayTag.class)) {
+ return NBTConstants.TYPE_LONG_ARRAY;
} else {
throw new IllegalArgumentException("Invalid tag classs ("
+ clazz.getName() + ").");
@@ -146,6 +150,8 @@ public final class NBTUtils {
return CompoundTag.class;
case NBTConstants.TYPE_INT_ARRAY:
return IntArrayTag.class;
+ case NBTConstants.TYPE_LONG_ARRAY:
+ return LongArrayTag.class;
default:
throw new IllegalArgumentException("Invalid tag type : " + type
+ ".");
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
index cc8df7c24..b007ea2eb 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
@@ -89,7 +89,7 @@ public class SchematicCommands {
)
@Deprecated
@CommandPermissions({ "worldedit.clipboard.load", "worldedit.schematic.load" })
- public void load(Player player, LocalSession session, @Optional("schematic") String formatName, String filename) throws FilenameException {
+ public void load(Player player, LocalSession session, @Optional("sponge") String formatName, String filename) throws FilenameException {
LocalConfiguration config = worldEdit.getConfiguration();
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java
index 3f3063032..103a795f6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java
@@ -76,7 +76,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
if (!schematic.containsKey("Materials")) {
return false;
}
- } catch (IOException e) {
+ } catch (Exception e) {
return false;
}
return true;
@@ -115,7 +115,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
if (!schematic.containsKey("Version")) {
return false;
}
- } catch (IOException e) {
+ } catch (Exception e) {
return false;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java
index 73f0cee8c..7b582203d 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java
@@ -202,6 +202,12 @@ public class SpongeSchematicReader extends NBTSchematicReader {
handler.updateNBT(state, values);
}
}
+ values.put("x", new IntTag(pt.getBlockX()));
+ values.put("y", new IntTag(pt.getBlockY()));
+ values.put("z", new IntTag(pt.getBlockZ()));
+ values.put("id", values.get("Id"));
+ values.remove("Id");
+ values.remove("Pos");
clipboard.setBlock(pt, new BaseBlock(state, new CompoundTag(values)));
} else {
clipboard.setBlock(pt, state);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java
index e93b498e3..bf42c5a75 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java
@@ -117,7 +117,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
int paletteMax = 0;
Map palette = new HashMap<>();
- List tileEntities = new ArrayList<>();
+ List tileEntities = new ArrayList<>();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
@@ -135,6 +135,13 @@ public class SpongeSchematicWriter implements ClipboardWriter {
values.put(entry.getKey(), entry.getValue());
}
+ values.remove("id"); // Remove 'id' if it exists. We want 'Id'
+
+ // Positions are kept in NBT, we don't want that.
+ values.remove("x");
+ values.remove("y");
+ values.remove("z");
+
values.put("Id", new StringTag(block.getNbtId()));
values.put("Pos", new IntArrayTag(new int[]{
x,
@@ -142,8 +149,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
z
}));
- CompoundTag tileEntityTag = new CompoundTag(values);
- tileEntities.add(tileEntityTag);
+ tileEntities.add(new CompoundTag(values));
}
String blockKey = block.toImmutableState().getAsString();