Exemplo n.º 1
0
        private ReadResults ReadListContents(ref INbtCollectionTag list)
        {
            ReadResults readResults;

            while (Reader.CanRead() && Reader.Peek() != ']')
            {
                int start = Reader.GetCursor();
                readResults = ReadValue(out INbtTag tag);
                if (!readResults.Successful)
                {
                    return(readResults);
                }
                if (!list.Add(tag))
                {
                    Reader.SetCursor(start);
                    return(ReadResults.Failure(CommandError.NbtCannotInsert(tag, list).WithContext(Reader)));
                }
                if (!HasElementSeparator())
                {
                    break;
                }
                if (Reader.CanRead())
                {
                    continue;
                }
                return(ReadResults.Failure(CommandError.ExpectedValue().WithContext(Reader)));
            }
            return(Reader.Expect(']'));
        }