Make NBT's get() always return a list if requested item ends with []

This commit is contained in:
altrisi committed 2021-04-21 00:25:14 +02:00
1 parent 0e84ef5d65
commit 6083b702f9
1 file changed
+3 -2
@@ -569,13 +569,14 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
@Override
public Value get(Value value)
{
NbtPathArgumentType.NbtPath path = cachePath(value.getString());
String valString = value.getString();
NbtPathArgumentType.NbtPath path = cachePath(valString);
try
{
List<Tag> tags = path.get(getTag());
if (tags.size()==0)
return Value.NULL;
if (tags.size()==1)
if (tags.size()==1 && !valString.endsWith("[]"))
return NBTSerializableValue.decodeTag(tags.get(0));
return ListValue.wrap(tags.stream().map(NBTSerializableValue::decodeTag).collect(Collectors.toList()));
}