From bfcc1678627b43997d5451c9b65e4fa5af1241e9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 29 Oct 2019 12:23:39 -0700 Subject: [PATCH] Flesh out NBT types --- .../com/gmail/nossr50/core/nbt/NBTByte.java | 1 + .../com/gmail/nossr50/core/nbt/NBTList.java | 3 +- .../nossr50/core/nbt/NBTTagCompound.java | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByte.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByte.java index ca1635243..b01a15f21 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByte.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByte.java @@ -25,4 +25,5 @@ public class NBTByte implements NBTBase { public void setValue(Byte value) { this.value = value; } + } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTList.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTList.java index f98653560..45b2bc8e6 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTList.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTList.java @@ -4,7 +4,6 @@ import java.util.List; public class NBTList implements NBTBase { - private int length; private String key; private List values; @@ -14,7 +13,7 @@ public class NBTList implements NBTBase { } public int getLength() { - return length; + return values.size(); } public String getKey() { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTTagCompound.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTTagCompound.java index 26dbbc7d4..d5ca3c542 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTTagCompound.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTTagCompound.java @@ -1,11 +1,19 @@ package com.gmail.nossr50.core.nbt; +import java.util.Collection; +import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; public class NBTTagCompound implements NBTBase { + private String key; private Map tagMap; + public NBTTagCompound(String key) { + tagMap = new LinkedHashMap<>(); + } + @Override public NBTType getNBTType() { return NBTType.COMPOUND; @@ -15,4 +23,32 @@ public class NBTTagCompound implements NBTBase { return tagMap.get(key); } + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public void addNBT(String tagKey, NBTBase nbt) { + tagMap.put(tagKey, nbt); + } + + public Collection getMapValues() { + return tagMap.values(); + } + + public Set getMapKeys() { + return tagMap.keySet(); + } + + public int getMapSize() { + return tagMap.size(); + } + + public void removeEntry(String tagKey) { + tagMap.remove(tagKey); + } } +