File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -78,10 +78,15 @@ private static function parseList(BinaryStream $stream) : ListTag{
78
78
if (self ::skipWhitespace ($ stream , "] " )){
79
79
while (!$ stream ->feof ()){
80
80
try {
81
- $ retval -> push ( self ::readValue ($ stream) );
81
+ $ value = self ::readValue ($ stream );
82
82
}catch (InvalidTagValueException $ e ){
83
83
throw new NbtDataException ("Data error: " . $ e ->getMessage ());
84
84
}
85
+ $ expectedType = $ retval ->getTagType ();
86
+ if ($ expectedType !== NBT ::TAG_End && $ expectedType !== $ value ->getType ()){
87
+ throw new NbtDataException ("Data error: lists can only contain one type of value " );
88
+ }
89
+ $ retval ->push ($ value );
85
90
if (self ::readBreak ($ stream , "] " )){
86
91
return $ retval ;
87
92
}
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public function testEmptyList() : void{
69
69
}
70
70
71
71
public function testMixedList () : void {
72
- $ this ->expectException (\TypeError::class); //TODO: throwing an engine level error on userdata is very bad ...
72
+ $ this ->expectExceptionMessage ( " lists can only contain one type of value " );
73
73
JsonNbtParser::parseJson ("{TestList:[1f, string2, 3b]} " );
74
74
}
75
75
You can’t perform that action at this time.
0 commit comments