package me.ryanw.overcast.impl;

import me.ryanw.overcast.api.OvercastPlayer;
import me.ryanw.overcast.impl.object.ParsedPlayer;
import org.jsoup.Connection;
import org.jsoup.Jsoup;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class OvercastAPI {

    private static String userAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36";
    private static int connectionTimeout = 3000;

    public static OvercastPlayer getPlayer(String username) throws IOException {
        Connection.Response response = Jsoup.connect("https://oc.tc/users/" + username)
                .method(Connection.Method.GET).userAgent(userAgent).timeout(connectionTimeout).execute();
        if (response.statusCode() != 200) return null;
        return new ParsedPlayer(response.parse());
    }

    public static List<OvercastPlayer> getPlayers(List<String> usernames) throws IOException {
        List<OvercastPlayer> playerList = new ArrayList<OvercastPlayer>();
        for (String username : usernames) {
            Connection.Response response = Jsoup.connect("https://oc.tc/users/" + username)
                    .method(Connection.Method.GET).userAgent(userAgent).timeout(connectionTimeout).execute();
            if (response.statusCode() != 200) break;
            playerList.add(new ParsedPlayer(response.parse()));
        }
        return playerList;
    }
}

@@ -578,104 +578,454 @@
     
-Connection.Response response = Jsoup.connect(%22https://oc.tc/users/%22 + username)
+String url = %22https://oc.tc/users/%22 + username;%0A        Connection.Response response = Jsoup.connect(url).method(Connection.Method.GET).userAgent(userAgent).timeout(connectionTimeout).execute();%0A        if (response.statusCode() != 200) return null;%0A        return new ParsedPlayer(response.parse());
 %0A    
+%7D%0A%0A
     
-        
+public static OvercastPlayer getPlayerByUrl(String url) throws IOException %7B%0A        Connection.Response response = Jsoup.connect(url)
 .met
@@ -1453,108 +1453,633 @@
     
-Connection.Response response = Jsoup.connect(%22https://oc.tc/users/%22 + username)%0A                    
+String url = %22https://oc.tc/users/%22 + username;%0A            Connection.Response response = Jsoup.connect(url).method(Connection.Method.GET).userAgent(userAgent).timeout(connectionTimeout).execute();%0A            if (response.statusCode() != 200) break;%0A            playerList.add(new ParsedPlayer(response.parse()));%0A        %7D%0A        return playerList;%0A    %7D%0A%0A    public static List%3COvercastPlayer%3E getPlayersByUrl(List%3CString%3E urls) throws IOException %7B%0A        List%3COvercastPlayer%3E playerList = new ArrayList%3COvercastPlayer%3E();%0A        for (String url : urls) %7B%0A            Connection.Response response = Jsoup.connect(url)
 .met

Add support for getting players by urls