Exemplo n.º 1
0
        public ReadResults Parse(IStringReader reader, DispatcherResources resources, out EntitySelector result)
        {
            int start = reader.GetCursor();
            EntitySelectorParser entitySelectorParser = new EntitySelectorParser(reader, resources, UseBedrock);
            ReadResults          readResults          = entitySelectorParser.Parse(out result);

            if (!readResults.Successful)
            {
                return(readResults);
            }

            if (result.MaxResults > 1 && SingleEntity)
            {
                reader.SetCursor(start);
                if (PlayersOnly)
                {
                    return(ReadResults.Failure(CommandError.SelectorTooManyPlayers().WithContext(reader)));
                }
                else
                {
                    return(ReadResults.Failure(CommandError.SelectorTooManyEntities().WithContext(reader)));
                }
            }
            if (result.IncludesEntities && PlayersOnly && !result.IsSelf)
            {
                reader.SetCursor(start);
                return(ReadResults.Failure(CommandError.SelectorPlayersOnly().WithContext(reader)));
            }

            return(ReadResults.Success());
        }