// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Util.java
// public class Util {
//     /**
//      * Gson instance that can parse data returned from the Mojang API.
//      */
//     public static final Gson GSON = new GsonBuilder()
//             .registerTypeAdapter(UUID.class, new UUIDTypeAdapter().nullSafe())
//             .create();
// 
//     public static String extractGroup(String string, Pattern pattern, int group) {
//         Matcher matcher = pattern.matcher(string);
//         return matcher.matches() ? matcher.group(group) : null;
//     }
// 
//     public static class LoggingRunnable implements Runnable {
//         private final Runnable delegate;
// 
//         public LoggingRunnable(Runnable delegate) {
//             this.delegate = delegate;
//         }
// 
//         @Override
//         public final void run() {
//             try {
//                 delegate.run();
//             } catch (RuntimeException e) {
//                 The5zigAPI.getLogger().error("Error in thread " + Thread.currentThread().getName(), e);
//                 throw e;
//             }
//         }
//     }
// 
//     /**
//      * Adapter that works with dashless UUIDs as retured by the Mojang API.
//      */
//     private static class UUIDTypeAdapter extends TypeAdapter<UUID> {
//         @Override
//         public void write(JsonWriter out, UUID value) throws IOException {
//             out.value(value.toString().replaceAll("-", ""));
//         }
// 
//         @Override
//         public UUID read(JsonReader in) throws IOException {
//             String stringId = in.nextString();
//             return new UUID(
//                     new BigInteger(stringId.substring(0, 16), 16).longValue(),
//                     new BigInteger(stringId.substring(16), 16).longValue());
//         }
//     }
// 
// }


import com.google.gson.reflect.TypeToken;
import net.frozenbit.plugin5zig.cubecraft.Util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.List;
package net.frozenbit.plugin5zig.cubecraft.commands.stalker;



public class MojangResponseHandler implements ResponseHandler<List<UserData>> {
    private static final TypeToken<List<UserData>> RESPONSE_TYPE = new TypeToken<List<UserData>>() {
    };

    @Override
    public List<UserData> handleResponse(HttpResponse response) throws IOException {
        StatusLine statusLine = response.getStatusLine();
        HttpEntity entity = response.getEntity();
        if (statusLine.getStatusCode() >= 300) {
            throw new HttpResponseException(
                    statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
        }
        if (entity == null) {
            throw new ClientProtocolException("Response contains no content");
        }
        String jsonResponseStr = EntityUtils.toString(entity);
// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/Util.java
// public class Util {
//     /**
//      * Gson instance that can parse data returned from the Mojang API.
//      */
//     public static final Gson GSON = new GsonBuilder()
//             .registerTypeAdapter(UUID.class, new UUIDTypeAdapter().nullSafe())
//             .create();
// 
//     public static String extractGroup(String string, Pattern pattern, int group) {
//         Matcher matcher = pattern.matcher(string);
//         return matcher.matches() ? matcher.group(group) : null;
//     }
// 
//     public static class LoggingRunnable implements Runnable {
//         private final Runnable delegate;
// 
//         public LoggingRunnable(Runnable delegate) {
//             this.delegate = delegate;
//         }
// 
//         @Override
//         public final void run() {
//             try {
//                 delegate.run();
//             } catch (RuntimeException e) {
//                 The5zigAPI.getLogger().error("Error in thread " + Thread.currentThread().getName(), e);
//                 throw e;
//             }
//         }
//     }
// 
//     /**
//      * Adapter that works with dashless UUIDs as retured by the Mojang API.
//      */
//     private static class UUIDTypeAdapter extends TypeAdapter<UUID> {
//         @Override
//         public void write(JsonWriter out, UUID value) throws IOException {
//             out.value(value.toString().replaceAll("-", ""));
//         }
// 
//         @Override
//         public UUID read(JsonReader in) throws IOException {
//             String stringId = in.nextString();
//             return new UUID(
//                     new BigInteger(stringId.substring(0, 16), 16).longValue(),
//                     new BigInteger(stringId.substring(16), 16).longValue());
//         }
//     }
// 
// }


// Path: src/main/java/net/frozenbit/plugin5zig/cubecraft/commands/stalker/MojangResponseHandler.java
import com.google.gson.reflect.TypeToken;
import net.frozenbit.plugin5zig.cubecraft.Util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.List;

package net.frozenbit.plugin5zig.cubecraft.commands.stalker;



public class MojangResponseHandler implements ResponseHandler<List<UserData>> {
    private static final TypeToken<List<UserData>> RESPONSE_TYPE = new TypeToken<List<UserData>>() {
    };

    @Override
    public List<UserData> handleResponse(HttpResponse response) throws IOException {
        StatusLine statusLine = response.getStatusLine();
        HttpEntity entity = response.getEntity();
        if (statusLine.getStatusCode() >= 300) {
            throw new HttpResponseException(
                    statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
        }
        if (entity == null) {
            throw new ClientProtocolException("Response contains no content");
        }
        String jsonResponseStr = EntityUtils.toString(entity);
        return Util.GSON.fromJson(jsonResponseStr, RESPONSE_TYPE.getType());