summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPugmatt <pugmatt@gmail.com>2020-07-07 03:26:34 -0400
committerPugmatt <pugmatt@gmail.com>2020-07-07 03:26:34 -0400
commit341f173e6cbad040ef50febe1b364e21c0e5835f (patch)
treed9ee3be7445a06d2a3370c20379ac5fc4d087abe
parentb098069f5269557a42bf4b3747f441a968e8b4d0 (diff)
downloadBedrockConnect-341f173e6cbad040ef50febe1b364e21c0e5835f.tar.gz
BedrockConnect-341f173e6cbad040ef50febe1b364e21c0e5835f.tar.bz2
BedrockConnect-341f173e6cbad040ef50febe1b364e21c0e5835f.zip
Update NBT syntax
-rw-r--r--serverlist-server/pom.xml1
-rw-r--r--serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/PipePlayer.java16
-rw-r--r--serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/listeners/PacketHandler.java20
-rw-r--r--serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/utils/PaletteManager.java28
4 files changed, 22 insertions, 43 deletions
diff --git a/serverlist-server/pom.xml b/serverlist-server/pom.xml
index 1c7bfb6..06999be 100644
--- a/serverlist-server/pom.xml
+++ b/serverlist-server/pom.xml
@@ -104,6 +104,7 @@
</exclusion>
</exclusions>
</dependency>
+
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
diff --git a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/PipePlayer.java b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/PipePlayer.java
index fabf8e3..26810b2 100644
--- a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/PipePlayer.java
+++ b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/PipePlayer.java
@@ -2,12 +2,10 @@ package main.com.pyratron.pugmatt.bedrockconnect;
import com.nukkitx.math.vector.Vector2f;
import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.nbt.CompoundTagBuilder;
+import com.nukkitx.nbt.NBTOutputStream;
+import com.nukkitx.nbt.NbtMap;
+import com.nukkitx.nbt.NbtMapBuilder;
import com.nukkitx.nbt.NbtUtils;
-import com.nukkitx.nbt.stream.NBTInputStream;
-import com.nukkitx.nbt.stream.NBTOutputStream;
-import com.nukkitx.nbt.tag.CompoundTag;
-import com.nukkitx.nbt.tag.ListTag;
import com.nukkitx.protocol.bedrock.Bedrock;
import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.BedrockServerSession;
@@ -37,7 +35,7 @@ public class PipePlayer {
private String uuid;
- private static final CompoundTag EMPTY_TAG = CompoundTagBuilder.builder().buildRootTag();
+ private static final NbtMap EMPTY_TAG = NbtMap.EMPTY;
private static final byte[] EMPTY_LEVEL_CHUNK_DATA;
static {
@@ -45,7 +43,7 @@ public class PipePlayer {
outputStream.write(new byte[258]); // Biomes + Border Size + Extra Data Size
try (NBTOutputStream stream = NbtUtils.createNetworkWriter(outputStream)) {
- stream.write(EMPTY_TAG);
+ stream.writeTag(EMPTY_TAG);
}
EMPTY_LEVEL_CHUNK_DATA = outputStream.toByteArray();
@@ -184,11 +182,11 @@ public class PipePlayer {
}
BiomeDefinitionListPacket biomePacket = new BiomeDefinitionListPacket();
- biomePacket.setTag(BedrockConnect.paletteManager.BIOMES);
+ biomePacket.setDefinitions(BedrockConnect.paletteManager.BIOMES);
session.sendPacket(biomePacket);
AvailableEntityIdentifiersPacket entityPacket = new AvailableEntityIdentifiersPacket();
- entityPacket.setTag(BedrockConnect.paletteManager.ENTITY_IDENTIFIERS);
+ entityPacket.setIdentifiers(BedrockConnect.paletteManager.ENTITY_IDENTIFIERS);
session.sendPacket(entityPacket);
InventoryContentPacket creativePacket = new InventoryContentPacket();
diff --git a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/listeners/PacketHandler.java b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/listeners/PacketHandler.java
index 85b9fd4..a86e1d5 100644
--- a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/listeners/PacketHandler.java
+++ b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/listeners/PacketHandler.java
@@ -6,10 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.nimbusds.jwt.SignedJWT;
import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.NbtUtils;
-import com.nukkitx.nbt.stream.NBTOutputStream;
-import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.network.util.Preconditions;
import com.nukkitx.protocol.bedrock.BedrockClient;
import com.nukkitx.protocol.bedrock.packet.*;
@@ -59,23 +56,6 @@ public class PacketHandler implements BedrockPacketHandler {
private boolean packetListening;
- private static final CompoundTag EMPTY_TAG = CompoundTagBuilder.builder().buildRootTag();
- private static final byte[] EMPTY_LEVEL_CHUNK_DATA;
-
- static {
- try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
- outputStream.write(new byte[258]); // Biomes + Border Size + Extra Data Size
-
- try (NBTOutputStream stream = NbtUtils.createNetworkWriter(outputStream)) {
- stream.write(EMPTY_TAG);
- }
-
- EMPTY_LEVEL_CHUNK_DATA = outputStream.toByteArray();
- }catch (IOException e) {
- throw new AssertionError("Unable to generate empty level chunk data");
- }
- }
-
@Override
public boolean handle(AdventureSettingsPacket packet) {
if(print)
diff --git a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/utils/PaletteManager.java b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/utils/PaletteManager.java
index b33c92a..9cdf41a 100644
--- a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/utils/PaletteManager.java
+++ b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/utils/PaletteManager.java
@@ -4,10 +4,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.nukkitx.nbt.NBTInputStream;
+import com.nukkitx.nbt.NbtList;
+import com.nukkitx.nbt.NbtMap;
import com.nukkitx.nbt.NbtUtils;
-import com.nukkitx.nbt.stream.NBTInputStream;
-import com.nukkitx.nbt.tag.CompoundTag;
-import com.nukkitx.nbt.tag.ListTag;
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -26,32 +26,32 @@ public class PaletteManager {
private ByteBuf cachedPalette;
- public ListTag<CompoundTag> CACHED_PALLETE;
+ public NbtList<NbtMap> CACHED_PALLETE;
- public static final CompoundTag BIOMES;
+ public static final NbtMap BIOMES;
static {
InputStream stream = BedrockConnect.class.getClassLoader().getResourceAsStream("tables/biome_definitions.dat");
- CompoundTag biomesTag;
+ NbtMap biomesTag;
try (NBTInputStream biomenbtInputStream = NbtUtils.createNetworkReader(stream)){
- biomesTag = (CompoundTag) biomenbtInputStream.readTag();
+ biomesTag = (NbtMap) biomenbtInputStream.readTag();
BIOMES = biomesTag;
} catch (Exception ex) {
throw new AssertionError(ex);
}
}
- public static final CompoundTag ENTITY_IDENTIFIERS;
+ public static final NbtMap ENTITY_IDENTIFIERS;
static {
InputStream stream = BedrockConnect.class.getClassLoader().getResourceAsStream("tables/entity_identifiers.dat");
- CompoundTag entityTag;
+ NbtMap entityTag;
try (NBTInputStream entitynbtInputStream = NbtUtils.createNetworkReader(stream)){
- entityTag = (CompoundTag) entitynbtInputStream.readTag();
+ entityTag = (NbtMap) entitynbtInputStream.readTag();
ENTITY_IDENTIFIERS = entityTag;
} catch (Exception ex) {
throw new AssertionError(ex);
@@ -83,7 +83,7 @@ public class PaletteManager {
byte[] bytes = Base64.getDecoder().decode(itemNode.get("nbt_b64").asText());
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
try {
- com.nukkitx.nbt.tag.CompoundTag tag = (com.nukkitx.nbt.tag.CompoundTag) NbtUtils.createReaderLE(bais).readTag();
+ NbtMap tag = (NbtMap) NbtUtils.createReaderLE(bais).readTag();
creativeItems.add(ItemData.of(itemNode.get("id").asInt(), damage, 1, tag));
} catch (IOException e) {
e.printStackTrace();
@@ -104,13 +104,13 @@ public class PaletteManager {
}
Map<String, Integer> blockIdToIdentifier = new HashMap<>();
- ListTag<CompoundTag> tag;
+ NbtList<NbtMap> tag;
NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream);
- ListTag<CompoundTag> blocksTag;
+ NbtList<NbtMap> blocksTag;
try {
- tag = (ListTag<CompoundTag>) nbtInputStream.readTag();
+ tag = (NbtList<NbtMap>) nbtInputStream.readTag();
nbtInputStream.close();
} catch (Exception ex) {
System.out.println("Failed to receive blocks palette");