Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
Make end tag singleton
Dieser Commit ist enthalten in:
Ursprung
8d68191b2c
Commit
13d2ae20d5
@ -399,7 +399,7 @@ public final class Spigot_v1_13_R1 implements BukkitImplAdapter<NBTBase> {
|
|||||||
} else if (foreign instanceof NBTTagString) {
|
} else if (foreign instanceof NBTTagString) {
|
||||||
return new StringTag(foreign.b_()); // data
|
return new StringTag(foreign.b_()); // data
|
||||||
} else if (foreign instanceof NBTTagEnd) {
|
} else if (foreign instanceof NBTTagEnd) {
|
||||||
return new EndTag();
|
return EndTag.INSTANCE;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
|
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ public class FaweCache {
|
|||||||
if (clazz.getName().startsWith("com.intellectualcrafters.jnbt")) {
|
if (clazz.getName().startsWith("com.intellectualcrafters.jnbt")) {
|
||||||
try {
|
try {
|
||||||
if (clazz.getName().equals("com.intellectualcrafters.jnbt.EndTag")) {
|
if (clazz.getName().equals("com.intellectualcrafters.jnbt.EndTag")) {
|
||||||
return new EndTag();
|
return EndTag.INSTANCE;
|
||||||
}
|
}
|
||||||
Field field = clazz.getDeclaredField("value");
|
Field field = clazz.getDeclaredField("value");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
@ -6,18 +6,24 @@ import com.boydti.fawe.object.exception.FaweException;
|
|||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class NBTStreamer {
|
public class NBTStreamer {
|
||||||
private final NBTInputStream is;
|
private final NBTInputStream is;
|
||||||
private final HashMap<String, BiConsumer> readers;
|
private final Map<String, BiConsumer> readers;
|
||||||
|
|
||||||
public NBTStreamer(NBTInputStream stream) {
|
public NBTStreamer(NBTInputStream stream) {
|
||||||
this.is = stream;
|
this.is = stream;
|
||||||
readers = new HashMap<>();
|
readers = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NBTStreamer(NBTInputStream stream, Map<String, BiConsumer> readers) {
|
||||||
|
this.is = stream;
|
||||||
|
this.readers = readers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the entire stream and runs the applicable readers
|
* Reads the entire stream and runs the applicable readers
|
||||||
*
|
*
|
||||||
|
@ -23,6 +23,9 @@ package com.sk89q.jnbt;
|
|||||||
* The {@code TAG_End} tag.
|
* The {@code TAG_End} tag.
|
||||||
*/
|
*/
|
||||||
public final class EndTag extends Tag {
|
public final class EndTag extends Tag {
|
||||||
|
public static final EndTag INSTANCE = new EndTag();
|
||||||
|
|
||||||
|
private EndTag() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
|
@ -526,7 +526,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
throw new IOException(
|
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 {
|
} else {
|
||||||
return new EndTag();
|
return EndTag.INSTANCE;
|
||||||
}
|
}
|
||||||
case NBTConstants.TYPE_BYTE:
|
case NBTConstants.TYPE_BYTE:
|
||||||
return new ByteTag(is.readByte());
|
return new ByteTag(is.readByte());
|
||||||
|
@ -217,7 +217,7 @@ final class NBTConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EndTag fromNative(NBTTagEnd other) {
|
public static EndTag fromNative(NBTTagEnd other) {
|
||||||
return new EndTag();
|
return EndTag.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongTag fromNative(NBTTagLong other) {
|
public static LongTag fromNative(NBTTagLong other) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren