package me.ryanw.overcast.impl;

import me.ryanw.overcast.api.OvercastFriend;
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 {

    public static OvercastPlayer getPlayer(String username) throws IOException {
        Connection.Response response = Jsoup.connect("https://oc.tc/users/" + username).method(Connection.Method.GET).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).execute();
            if (response.statusCode() != 200) break;
            playerList.add(new ParsedPlayer(response.parse()));
        }
        return playerList;
    }
}

@@ -329,16 +329,217 @@
 tAPI %7B%0A%0A
+    private static String userAgent = %22Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36%22;%0A    private static int connectionTimeout = 3000;%0A%0A
     publ
@@ -690,32 +690,49 @@
 rs/%22 + username)
+%0A                
 .method(Connecti
@@ -738,32 +738,80 @@
 ion.Method.GET).
+userAgent(userAgent).timeout(connectionTimeout).
 execute();%0A     
@@ -1223,16 +1223,37 @@
 sername)
+%0A                    
 .method(
@@ -1275,16 +1275,64 @@
 od.GET).
+userAgent(userAgent).timeout(connectionTimeout).
 execute(

Add connection timeout & user agent