Added byte arrays to the nbt api.

This commit is contained in:
Brianna 2021-04-12 11:06:45 -05:00
parent 9b9f0b9a52
commit 75c11b19a7
49 changed files with 333 additions and 38 deletions

View File

@ -21,6 +21,8 @@ public interface NBTCompound {
NBTCompound set(String tag, int[] i); NBTCompound set(String tag, int[] i);
NBTCompound set(String tag, byte[] b);
NBTCompound set(String tag, UUID u); NBTCompound set(String tag, UUID u);
NBTCompound remove(String tag); NBTCompound remove(String tag);
@ -45,6 +47,8 @@ public interface NBTCompound {
int[] getIntArray(String tag); int[] getIntArray(String tag);
byte[] getByteArray(String tag);
NBTCompound getCompound(String tag); NBTCompound getCompound(String tag);
Set<String> getKeys(); Set<String> getKeys();

View File

@ -20,6 +20,8 @@ public interface NBTObject {
int[] asIntArray(); int[] asIntArray();
byte[] asByteArray();
Set<String> getKeys(); Set<String> getKeys();
NBTCompound asCompound(); NBTCompound asCompound();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_10_R1.ItemStack nmsItem; private final net.minecraft.server.v1_10_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_10_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_10_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -1,5 +1,6 @@
package com.songoda.core.nms.v1_11_R1.nbt; package com.songoda.core.nms.v1_11_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTItem; import com.songoda.core.nms.nbt.NBTItem;
import net.minecraft.server.v1_11_R1.NBTTagCompound; import net.minecraft.server.v1_11_R1.NBTTagCompound;
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
@ -7,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_11_R1.ItemStack nmsItem; private final net.minecraft.server.v1_11_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_11_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_11_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());
@ -22,6 +23,17 @@ public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
} }
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public void addExtras() { public void addExtras() {
} }

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_12_R1.ItemStack nmsItem; private final net.minecraft.server.v1_12_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_12_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_12_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_13_R1.ItemStack nmsItem; private final net.minecraft.server.v1_13_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_13_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_13_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.getKeys(); return compound.getKeys();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -1,5 +1,6 @@
package com.songoda.core.nms.v1_13_R2.nbt; package com.songoda.core.nms.v1_13_R2.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTItem; import com.songoda.core.nms.nbt.NBTItem;
import net.minecraft.server.v1_13_R2.NBTTagCompound; import net.minecraft.server.v1_13_R2.NBTTagCompound;
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
@ -7,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_13_R2.ItemStack nmsItem; private final net.minecraft.server.v1_13_R2.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_13_R2.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_13_R2.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());
@ -22,6 +23,17 @@ public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
} }
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public void addExtras() { public void addExtras() {
} }

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.getKeys(); return compound.getKeys();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -1,5 +1,6 @@
package com.songoda.core.nms.v1_14_R1.nbt; package com.songoda.core.nms.v1_14_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTItem; import com.songoda.core.nms.nbt.NBTItem;
import net.minecraft.server.v1_14_R1.NBTTagCompound; import net.minecraft.server.v1_14_R1.NBTTagCompound;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
@ -7,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_14_R1.ItemStack nmsItem; private final net.minecraft.server.v1_14_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_14_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_14_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());
@ -22,6 +23,17 @@ public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
} }
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public void addExtras() { public void addExtras() {
} }

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.getKeys(); return compound.getKeys();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -1,5 +1,6 @@
package com.songoda.core.nms.v1_15_R1.nbt; package com.songoda.core.nms.v1_15_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTEntity; import com.songoda.core.nms.nbt.NBTEntity;
import net.minecraft.server.v1_15_R1.BlockPosition; import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.Entity; import net.minecraft.server.v1_15_R1.Entity;
@ -56,6 +57,17 @@ public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
return spawn(location); return spawn(location);
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public void addExtras() { public void addExtras() {
compound.setString("entity_type", IRegistry.ENTITY_TYPE.getKey(nmsEntity.getEntityType()).toString()); compound.setString("entity_type", IRegistry.ENTITY_TYPE.getKey(nmsEntity.getEntityType()).toString());

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_15_R1.ItemStack nmsItem; private final net.minecraft.server.v1_15_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_15_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_15_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.getKeys(); return compound.getKeys();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -1,5 +1,6 @@
package com.songoda.core.nms.v1_16_R1.nbt; package com.songoda.core.nms.v1_16_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTItem; import com.songoda.core.nms.nbt.NBTItem;
import net.minecraft.server.v1_16_R1.NBTTagCompound; import net.minecraft.server.v1_16_R1.NBTTagCompound;
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
@ -7,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_16_R1.ItemStack nmsItem; private final net.minecraft.server.v1_16_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_16_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_16_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());
@ -22,6 +23,17 @@ public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
} }
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public void addExtras() { public void addExtras() {
} }

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.getKeys(); return compound.getKeys();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_16_R2.ItemStack nmsItem; private final net.minecraft.server.v1_16_R2.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_16_R2.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_16_R2.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public NBTCompound asCompound() { public NBTCompound asCompound() {
return new NBTCompoundImpl(compound.getCompound(tag)); return new NBTCompoundImpl(compound.getCompound(tag));

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return getNBTObject(tag).asByteArray();
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -13,7 +13,7 @@ import java.io.IOException;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_16_R3.ItemStack nmsItem; private final net.minecraft.server.v1_16_R3.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_16_R3.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_16_R3.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());
@ -28,29 +28,6 @@ public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
} }
} }
@Override
public byte[] serialize(String... exclusions) {
try (ByteArrayOutputStream stream = new ByteArrayOutputStream(); BukkitObjectOutputStream bukkitStream = new BukkitObjectOutputStream(stream)) {
bukkitStream.writeObject(nmsItem);
return stream.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Override
public void deSerialize(byte[] serialized) {
try (BukkitObjectInputStream stream = new BukkitObjectInputStream(
new ByteArrayInputStream(serialized))) {
nmsItem = (net.minecraft.server.v1_16_R3.ItemStack) stream.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
@Override @Override
public void addExtras() { public void addExtras() {
} }

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public NBTCompound asCompound() { public NBTCompound asCompound() {
return new NBTCompoundImpl(compound.getCompound(tag)); return new NBTCompoundImpl(compound.getCompound(tag));

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
set(tag + "Most", u.getMostSignificantBits()); set(tag + "Most", u.getMostSignificantBits());
@ -137,6 +143,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_8_R1.ItemStack nmsItem; private final net.minecraft.server.v1_8_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_8_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_8_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
set(tag + "Most", u.getMostSignificantBits()); set(tag + "Most", u.getMostSignificantBits());
@ -137,6 +143,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_8_R2.ItemStack nmsItem; private final net.minecraft.server.v1_8_R2.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_8_R2.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_8_R2.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
set(tag + "Most", u.getMostSignificantBits()); set(tag + "Most", u.getMostSignificantBits());
@ -137,6 +143,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -1,5 +1,6 @@
package com.songoda.core.nms.v1_8_R3.nbt; package com.songoda.core.nms.v1_8_R3.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTEntity; import com.songoda.core.nms.nbt.NBTEntity;
import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityTypes; import net.minecraft.server.v1_8_R3.EntityTypes;
@ -65,6 +66,17 @@ public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
return spawn(location); return spawn(location);
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public void addExtras() { public void addExtras() {
String key = EntityTypes.b(nmsEntity); // Changed in 1.12 String key = EntityTypes.b(nmsEntity); // Changed in 1.12

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_8_R3.ItemStack nmsItem; private final net.minecraft.server.v1_8_R3.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_8_R3.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_8_R3.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_9_R1.ItemStack nmsItem; private final net.minecraft.server.v1_9_R1.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_9_R1.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_9_R1.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();

View File

@ -74,6 +74,12 @@ public class NBTCompoundImpl implements NBTCompound {
return this; return this;
} }
@Override
public NBTCompound set(String tag, byte[] b) {
compound.setByteArray(tag, b);
return this;
}
@Override @Override
public NBTCompound set(String tag, UUID u) { public NBTCompound set(String tag, UUID u) {
compound.a(tag, u); compound.a(tag, u);
@ -136,6 +142,11 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asIntArray(); return getNBTObject(tag).asIntArray();
} }
@Override
public byte[] getByteArray(String tag) {
return new byte[0];
}
@Override @Override
public NBTCompound getCompound(String tag) { public NBTCompound getCompound(String tag) {
if (has(tag)) { if (has(tag)) {

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem { public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
private net.minecraft.server.v1_9_R2.ItemStack nmsItem; private final net.minecraft.server.v1_9_R2.ItemStack nmsItem;
public NBTItemImpl(net.minecraft.server.v1_9_R2.ItemStack nmsItem) { public NBTItemImpl(net.minecraft.server.v1_9_R2.ItemStack nmsItem) {
super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound()); super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound());

View File

@ -56,6 +56,11 @@ public class NBTObjectImpl implements NBTObject {
return compound.getIntArray(tag); return compound.getIntArray(tag);
} }
@Override
public byte[] asByteArray() {
return compound.getByteArray(tag);
}
@Override @Override
public Set<String> getKeys() { public Set<String> getKeys() {
return compound.c(); return compound.c();