Skip to content

Commit c01e084

Browse files
committed
Added NbtOptions.TypeForEmptyList
1 parent 988d01d commit c01e084

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

MCServerSharp.NBT/NbtOptions.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ public struct NbtOptions
1010
IsBigEndian = true,
1111
IsVarArrayLength = false,
1212
IsVarStringLength = false,
13-
MaxDepth = DefaultMaxDepth
13+
MaxDepth = DefaultMaxDepth,
14+
TypeForEmptyList = NbtType.End,
1415
};
1516

1617
public bool IsBigEndian { get; set; }
1718
public bool IsVarArrayLength { get; set; }
1819
public bool IsVarStringLength { get; set; }
1920
public int MaxDepth { get; set; }
21+
22+
/// <summary>
23+
/// The expected type for empty list tags.
24+
/// Can be <see langword="null"/> to skip validation.
25+
/// </summary>
26+
public NbtType? TypeForEmptyList { get; set; }
2027
}
2128
}

MCServerSharp.NBT/NbtReader.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ public NbtReadStatus TryRead()
268268

269269
if (status != NbtReadStatus.Done)
270270
goto ClearReturn;
271-
if (listLength <= 0 && listType != NbtType.End)
271+
if (listLength <= 0 &&
272+
Options.TypeForEmptyList.HasValue && listType != Options.TypeForEmptyList.GetValueOrDefault())
272273
{
273274
status = NbtReadStatus.InvalidListLength;
274275
goto ClearReturn;

0 commit comments

Comments
 (0)