diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java index 245a1c42..226d7b61 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java @@ -262,7 +262,8 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Associates a given Java primitive value, list, map or NbtBase with a certain key. *

- * If the value is NULL, the corresponding key is removed. + * If the value is NULL, the corresponding key is removed. Any Map or List will be converted + * to a corresponding NbtCompound or NbtList. * * @param key - the name of the new entry, * @param value - the value of the new entry, or NULL to remove the current value. @@ -270,6 +271,13 @@ public interface NbtCompound extends NbtBase>>, Iterable< */ public abstract NbtCompound putObject(String key, Object value); + /** + * Retrieve the primitive object, NbtList or NbtCompound associated with the given key. + * @param key - the key of the object to find. + * @return The object with this key, or NULL if we couldn't find anything. + */ + public abstract Object getObject(String key); + /** * Retrieve the compound (map) value of an entry identified by a given key. * @param key - the key of the entry. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/WrappedCompound.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/WrappedCompound.java index 222d8340..ae277973 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/WrappedCompound.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/WrappedCompound.java @@ -274,6 +274,16 @@ class WrappedCompound implements NbtWrapper>>, Iterable base = getValue(key); + + if (base != null && base.getType() != NbtType.TAG_LIST && base.getType() != NbtType.TAG_COMPOUND) + return base.getValue(); + else + return base; + } + /** * Retrieve the byte value of an entry identified by a given key. * @param key - the key of the entry.