class PlayersType implements StringType<List<Player>> {

    @Override
    public List<Player> parse(StringReader reader) throws CommandSyntaxException {
        var argument = reader.peek() == '"' ? reader.readQuotedString() : Readers.until(reader, ' ');
        
        if (argument.equalsIgnoreCase("@a")) {
            return online();
        }
        
        var online = online();
        var players = new ArrayList<Player>();
        var names = Readers.COMMA.split(argument);
        for (var name : names) {
            if (name.equalsIgnoreCase("@r")) {
                players.add(online.get(ThreadLocalRandom.current().nextInt(online.size())));
                continue;
            }
            
            var player = server.getPlayerExact(name);
            if (player != null) {
                players.add(player);
                
            } else if (name.equalsIgnoreCase("@a")) {
                throw INVALID.createWithContext(reader);
                
            } else {
                throw UNKNOWN.createWithContext(reader, name);
            }
        }
        
        
        return players;
    }

    public  PlayersType();

}