mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 11:26:42 +00:00
Reorder BuildInClipboardFormat and document changed JNBT classes (#807)
* Get rid of FastSchematicReader/Writer and document changed JNBT classes This commit includes changes from upstream to the schematic classes (`com.sk89q.worldedit.extent.clipboard.io`). It also documents the JNBT classes, specifying what has been changed in FAWE. This was done in preparation for the upcoming move to adventure-nbt. The PlotSquared schematic handler classes will now use SpongeSchematicReader/Writer rather than FastSchematicReader/Writer. This is yet untested and the entire branch is a W.I.P. * Fix JNBT mutability misuse in FAWE FAWE previously had mutable compound and list tags. The previous commit changed that, and this commit will fix misuse of the tag API. I've tried to identify the places where mutability was assumed, but I might have missed something. This needs quite extensive testing. This is yet another change which increases upstream compatibility in FAWE. * Fix FAWE_Spigot_<..>#getEntity * Fix JNBT usage in the AsyncBlockState code * Readd FastSchematicReader/Writer and add a new schematic format (`FAST`) * Update dead repository * Implement missing AsyncChunk#getTileEntities * handle entities properly and add "brokenentity" format * Fix fast schematic reader lazily reading means it's read in order of appearance in the inputstream so we need to read schematic version first (skip past everything) and then reset the stream * Fix p2 FAWE * Go back to fast schematics in P2/CompressedSchematicTag (#819) * Fix compile Co-authored-by: N0tMyFaultOG <mc.cache@web.de> Co-authored-by: Alexander Söderberg <Sauilitired@users.noreply.github.com> Co-authored-by: dordsor21 <dordsor21@gmail.com> Co-authored-by: Aurora <aurora@relanet.eu>
This commit is contained in:
committed by
GitHub
parent
efcca5b66f
commit
3f0b9a2a92
@ -26,11 +26,6 @@ import java.util.Locale;
|
||||
*/
|
||||
public final class ByteArrayTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_BYTE_ARRAY;
|
||||
}
|
||||
|
||||
private final byte[] value;
|
||||
|
||||
/**
|
||||
@ -61,4 +56,11 @@ public final class ByteArrayTag extends Tag {
|
||||
return "TAG_Byte_Array(" + hex + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_BYTE_ARRAY;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.jnbt.fawe.NumberTag;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Byte} tag.
|
||||
*/
|
||||
public final class ByteTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_BYTE;
|
||||
}
|
||||
|
||||
private final byte value;
|
||||
|
||||
@ -50,4 +48,11 @@ public final class ByteTag extends NumberTag {
|
||||
return "TAG_Byte(" + value + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_BYTE;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.jnbt.fawe.NumberTag;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -34,12 +35,7 @@ import java.util.UUID;
|
||||
*/
|
||||
public class CompoundTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_COMPOUND;
|
||||
}
|
||||
|
||||
private Map<String, Tag> value;
|
||||
private final Map<String, Tag> value;
|
||||
|
||||
/**
|
||||
* Creates the tag with an empty name.
|
||||
@ -48,7 +44,7 @@ public class CompoundTag extends Tag {
|
||||
*/
|
||||
public CompoundTag(Map<String, Tag> value) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.value = Collections.unmodifiableMap(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +54,7 @@ public class CompoundTag extends Tag {
|
||||
* @return true if the tag contains the given key
|
||||
*/
|
||||
public boolean containsKey(String key) {
|
||||
return getValue().containsKey(key);
|
||||
return value.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,17 +62,6 @@ public class CompoundTag extends Tag {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new compound tag with the given values.
|
||||
*
|
||||
* @param value the value
|
||||
* @return the new compound tag
|
||||
*/
|
||||
public CompoundTag setValue(Map<String, Tag> value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a compound tag builder.
|
||||
*
|
||||
@ -96,7 +81,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a byte array
|
||||
*/
|
||||
public byte[] getByteArray(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ByteArrayTag) {
|
||||
return ((ByteArrayTag) tag).getValue();
|
||||
} else {
|
||||
@ -114,7 +99,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a byte
|
||||
*/
|
||||
public byte getByte(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
} else {
|
||||
@ -132,7 +117,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a double
|
||||
*/
|
||||
public double getDouble(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue();
|
||||
} else {
|
||||
@ -151,9 +136,25 @@ public class CompoundTag extends Tag {
|
||||
* @return a double
|
||||
*/
|
||||
public double asDouble(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
if (tag instanceof NumberTag) {
|
||||
return ((NumberTag) tag).getValue().doubleValue();
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -169,7 +170,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a float
|
||||
*/
|
||||
public float getFloat(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue();
|
||||
} else {
|
||||
@ -187,7 +188,7 @@ public class CompoundTag extends Tag {
|
||||
* @return an int array
|
||||
*/
|
||||
public int[] getIntArray(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof IntArrayTag) {
|
||||
return ((IntArrayTag) tag).getValue();
|
||||
} else {
|
||||
@ -205,7 +206,7 @@ public class CompoundTag extends Tag {
|
||||
* @return an int
|
||||
*/
|
||||
public int getInt(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
} else {
|
||||
@ -224,9 +225,25 @@ public class CompoundTag extends Tag {
|
||||
* @return an int
|
||||
*/
|
||||
public int asInt(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
if (tag instanceof NumberTag) {
|
||||
return ((NumberTag) tag).getValue().intValue();
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue().intValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue().intValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue().intValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -242,7 +259,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a list of tags
|
||||
*/
|
||||
public List<Tag> getList(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ListTag) {
|
||||
return ((ListTag) tag).getValue();
|
||||
} else {
|
||||
@ -260,7 +277,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a tag list instance
|
||||
*/
|
||||
public ListTag getListTag(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ListTag) {
|
||||
return (ListTag) tag;
|
||||
} else {
|
||||
@ -273,7 +290,7 @@ public class CompoundTag extends Tag {
|
||||
*
|
||||
* <p>If the key does not exist or its value is not a list tag,
|
||||
* then an empty list will be returned. If the given key references
|
||||
* a list but the list of a different type, then an empty
|
||||
* a list but the list of of a different type, then an empty
|
||||
* list will also be returned.</p>
|
||||
*
|
||||
* @param key the key
|
||||
@ -283,7 +300,7 @@ public class CompoundTag extends Tag {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Tag> List<T> getList(String key, Class<T> listType) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ListTag) {
|
||||
ListTag listTag = (ListTag) tag;
|
||||
if (listTag.getType().equals(listType)) {
|
||||
@ -299,14 +316,14 @@ public class CompoundTag extends Tag {
|
||||
/**
|
||||
* Get a {@code long[]} named with the given key.
|
||||
*
|
||||
* <p>If the key does not exist or its value is not a long array tag,
|
||||
* <p>If the key does not exist or its value is not an long array tag,
|
||||
* then an empty array will be returned.</p>
|
||||
*
|
||||
* @param key the key
|
||||
* @return an int array
|
||||
*/
|
||||
public long[] getLongArray(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof LongArrayTag) {
|
||||
return ((LongArrayTag) tag).getValue();
|
||||
} else {
|
||||
@ -324,7 +341,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a long
|
||||
*/
|
||||
public long getLong(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
} else {
|
||||
@ -343,9 +360,25 @@ public class CompoundTag extends Tag {
|
||||
* @return a long
|
||||
*/
|
||||
public long asLong(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
if (tag instanceof NumberTag) {
|
||||
return ((NumberTag) tag).getValue().longValue();
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue().longValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue().longValue();
|
||||
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
@ -361,7 +394,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a short
|
||||
*/
|
||||
public short getShort(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
} else {
|
||||
@ -379,7 +412,7 @@ public class CompoundTag extends Tag {
|
||||
* @return a string
|
||||
*/
|
||||
public String getString(String key) {
|
||||
Tag tag = getValue().get(key);
|
||||
Tag tag = value.get(key);
|
||||
if (tag instanceof StringTag) {
|
||||
return ((StringTag) tag).getValue();
|
||||
} else {
|
||||
@ -388,17 +421,17 @@ public class CompoundTag extends Tag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toRaw() {
|
||||
HashMap<String, Object> raw = new HashMap<>();
|
||||
if (this.getValue().isEmpty()) {
|
||||
return raw;
|
||||
public String toString() {
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n");
|
||||
for (Map.Entry<String, Tag> entry : value.entrySet()) {
|
||||
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
for (Map.Entry<String, Tag> entry : getValue().entrySet()) {
|
||||
raw.put(entry.getKey(), entry.getValue().toRaw());
|
||||
}
|
||||
return raw;
|
||||
bldr.append("}");
|
||||
return bldr.toString();
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
public UUID getUUID() {
|
||||
long most = getLong("UUIDMost");
|
||||
long least = getLong("UUIDLeast");
|
||||
@ -421,15 +454,21 @@ public class CompoundTag extends Tag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Map<String, Tag> value = getValue();
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_Compound").append(": ").append(getValue().size()).append(" entries\r\n{\r\n");
|
||||
for (Map.Entry<String, Tag> entry : getValue().entrySet()) {
|
||||
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
bldr.append("}");
|
||||
return bldr.toString();
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_COMPOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toRaw() {
|
||||
HashMap<String, Object> raw = new HashMap<>();
|
||||
if (this.getValue().isEmpty()) {
|
||||
return raw;
|
||||
}
|
||||
for (Map.Entry<String, Tag> entry : getValue().entrySet()) {
|
||||
raw.put(entry.getKey(), entry.getValue().toRaw());
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.jnbt.fawe.NumberTag;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Double} tag.
|
||||
*/
|
||||
public final class DoubleTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_DOUBLE;
|
||||
}
|
||||
|
||||
private final double value;
|
||||
|
||||
@ -50,4 +48,11 @@ public final class DoubleTag extends NumberTag {
|
||||
return "TAG_Double(" + value + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_DOUBLE;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -24,11 +24,6 @@ package com.sk89q.jnbt;
|
||||
*/
|
||||
public final class EndTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_END;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return null;
|
||||
@ -39,4 +34,11 @@ public final class EndTag extends Tag {
|
||||
return "TAG_End";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_END;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.jnbt.fawe.NumberTag;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Float} tag.
|
||||
*/
|
||||
public final class FloatTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_FLOAT;
|
||||
}
|
||||
|
||||
private final float value;
|
||||
|
||||
@ -50,4 +48,11 @@ public final class FloatTag extends NumberTag {
|
||||
return "TAG_Float(" + value + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_FLOAT;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -28,11 +28,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public final class IntArrayTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_INT_ARRAY;
|
||||
}
|
||||
|
||||
private final int[] value;
|
||||
|
||||
/**
|
||||
@ -64,4 +59,11 @@ public final class IntArrayTag extends Tag {
|
||||
return "TAG_Int_Array(" + hex + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_INT_ARRAY;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.jnbt.fawe.NumberTag;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Int} tag.
|
||||
*/
|
||||
public final class IntTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_INT;
|
||||
}
|
||||
|
||||
private final int value;
|
||||
|
||||
@ -50,4 +48,11 @@ public final class IntTag extends NumberTag {
|
||||
return "TAG_Int(" + value + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_INT;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -31,11 +30,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public final class ListTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LIST;
|
||||
}
|
||||
|
||||
private final Class<? extends Tag> type;
|
||||
private final List<Tag> value;
|
||||
|
||||
@ -421,18 +415,6 @@ public final class ListTag extends Tag {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList toRaw() {
|
||||
ArrayList<Object> raw = new ArrayList<>();
|
||||
if (this.value.isEmpty()) {
|
||||
return raw;
|
||||
}
|
||||
for (Tag elem : this.value) {
|
||||
raw.add(elem.toRaw());
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
@ -444,4 +426,11 @@ public final class ListTag extends Tag {
|
||||
return bldr.toString();
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LIST;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -28,11 +28,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class LongArrayTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LONG_ARRAY;
|
||||
}
|
||||
|
||||
private final long[] value;
|
||||
|
||||
/**
|
||||
@ -64,4 +59,11 @@ public class LongArrayTag extends Tag {
|
||||
return "TAG_Long_Array(" + hex + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LONG_ARRAY;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.jnbt.fawe.NumberTag;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Long} tag.
|
||||
*/
|
||||
public final class LongTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LONG;
|
||||
}
|
||||
|
||||
private final long value;
|
||||
|
||||
@ -50,4 +48,11 @@ public final class LongTag extends NumberTag {
|
||||
return "TAG_Long(" + value + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_LONG;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -20,14 +20,13 @@
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* A class which holds constant values.
|
||||
*/
|
||||
public final class NBTConstants {
|
||||
|
||||
public static final Charset CHARSET = StandardCharsets.UTF_8;
|
||||
public static final Charset CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
public static final int TYPE_END = 0;
|
||||
public static final int TYPE_BYTE = 1;
|
||||
|
@ -32,6 +32,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// THIS CLASS HAS BEEN HEAVILY MODIFIED BY FAWE
|
||||
|
||||
/**
|
||||
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
|
||||
* streams, and produces an object graph of subclasses of the {@code Tag}
|
||||
@ -469,7 +471,7 @@ public final class NBTInputStream implements Closeable {
|
||||
case NBTConstants.TYPE_END:
|
||||
if (depth == 0) {
|
||||
throw new IOException(
|
||||
"TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
|
||||
"TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
// THIS CLASS HAS BEEN HEAVILY MODIFIED BY FAWE
|
||||
|
||||
/**
|
||||
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
|
||||
* {@code Tag} objects to an underlying {@code OutputStream}.
|
||||
|
@ -49,7 +49,7 @@ public final class NBTUtils {
|
||||
return "TAG_Byte_Array";
|
||||
} else if (clazz.equals(ByteTag.class)) {
|
||||
return "TAG_Byte";
|
||||
} else if (CompoundTag.class.isAssignableFrom(clazz)) {
|
||||
} else if (clazz.equals(CompoundTag.class)) {
|
||||
return "TAG_Compound";
|
||||
} else if (clazz.equals(DoubleTag.class)) {
|
||||
return "TAG_Double";
|
||||
|
@ -1,41 +0,0 @@
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Some data with a name
|
||||
*/
|
||||
public class NamedData<T> {
|
||||
private final String name;
|
||||
private final T data;
|
||||
|
||||
/**
|
||||
* Create a new named tag.
|
||||
*
|
||||
* @param name the name
|
||||
* @param data the data
|
||||
*/
|
||||
public NamedData(String name, T data) {
|
||||
checkNotNull(name);
|
||||
this.name = name;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the tag.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag.
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
public T getValue() {
|
||||
return data;
|
||||
}
|
||||
}
|
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import com.sk89q.jnbt.fawe.NumberTag;
|
||||
|
||||
/**
|
||||
* The {@code TAG_Short} tag.
|
||||
*/
|
||||
public final class ShortTag extends NumberTag {
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_SHORT;
|
||||
}
|
||||
|
||||
private final short value;
|
||||
|
||||
@ -50,4 +48,11 @@ public final class ShortTag extends NumberTag {
|
||||
return "TAG_Short(" + value + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_SHORT;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -26,11 +26,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public final class StringTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_STRING;
|
||||
}
|
||||
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
@ -54,4 +49,11 @@ public final class StringTag extends Tag {
|
||||
return "TAG_String(" + value + ")";
|
||||
}
|
||||
|
||||
// FAWE Start
|
||||
@Override
|
||||
public int getTypeCode() {
|
||||
return NBTConstants.TYPE_STRING;
|
||||
}
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -31,10 +31,12 @@ public abstract class Tag {
|
||||
*/
|
||||
public abstract Object getValue();
|
||||
|
||||
// FAWE Start
|
||||
public Object toRaw() {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
public abstract int getTypeCode();
|
||||
// FAWE End
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CompressedCompoundTag<T> extends CompoundTag {
|
||||
|
||||
private T in;
|
||||
|
||||
public CompressedCompoundTag(T in) {
|
||||
@ -41,4 +42,5 @@ public abstract class CompressedCompoundTag<T> extends CompoundTag {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package com.sk89q.jnbt;
|
||||
package com.sk89q.jnbt.fawe;
|
||||
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.boydti.fawe.object.io.FastByteArraysInputStream;
|
||||
import com.sk89q.jnbt.CompressedCompoundTag;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
@ -10,6 +12,7 @@ import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CompressedSchematicTag extends CompressedCompoundTag<Clipboard> {
|
||||
|
||||
public CompressedSchematicTag(Clipboard holder) {
|
||||
super(holder);
|
||||
}
|
||||
@ -26,4 +29,5 @@ public class CompressedSchematicTag extends CompressedCompoundTag<Clipboard> {
|
||||
FastByteArraysInputStream in = new FastByteArraysInputStream(blocksOut.toByteArrays());
|
||||
return new LZ4BlockInputStream(in);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,13 @@
|
||||
package com.sk89q.jnbt;
|
||||
package com.sk89q.jnbt.fawe;
|
||||
|
||||
import com.sk89q.jnbt.Tag;
|
||||
|
||||
/**
|
||||
* A numerical {@link Tag}
|
||||
*/
|
||||
public abstract class NumberTag extends Tag {
|
||||
|
||||
@Override
|
||||
public abstract Number getValue();
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* These are classes added by FAWE. They do not exist in WorldEdit
|
||||
*/
|
||||
package com.sk89q.jnbt.fawe;
|
Reference in New Issue
Block a user