/**
 * Copyright © 2013 tuxed <write@imaginarycode.com>
 * This work is free. You can redistribute it and/or modify it under the
 * terms of the Do What The Fuck You Want To Public License, Version 2,
 * as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
 */
package com.imaginarycode.minecraft.redisbungee.util;

import com.google.common.io.ByteStreams;
import com.google.gson.reflect.TypeToken;
import com.imaginarycode.minecraft.redisbungee.RedisBungee;

import java.io.IOException;
import java.lang.reflect.Type;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;

public class NameFetcher {
    public static List<String> nameHistoryFromUuid(UUID uuid) throws IOException {
        URLConnection connection = new URL("https://api.mojang.com/user/profiles/" + uuid.toString().replace("-", "").toLowerCase() + "/names").openConnection();
        String text = new String(ByteStreams.toByteArray(connection.getInputStream()));
        Type listType = new TypeToken<List<String>>() {}.getType();
        return RedisBungee.getGson().fromJson(text, listType);
    }
}
@@ -358,22 +358,29 @@
 mon.
-io.ByteStreams
+collect.ImmutableList
 ;%0Aim
@@ -500,156 +500,352 @@
 io.I
-OException;%0Aimport java.lang.reflect.Type;%0Aimport java.net.URL;%0Aimport java.net.URLConnection;%0Aimport java.util.*;%0A%0Apublic class NameFetcher
+nputStreamReader;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.URL;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.UUID;%0Aimport java.util.concurrent.Callable;%0A%0A/* Credits to evilmidget38 for this class. I modified it to use Gson. */%0Aclass NameFetcher implements Callable%3CMap%3CUUID, String%3E%3E
  %7B%0A    p
 ubli
@@ -844,21 +844,22 @@
    p
-ublic
+rivate
  static 
 List
@@ -858,50 +858,283 @@
 tic 
-List%3CString%3E nameHistoryFromUuid(
+final String PROFILE_URL = %22https://sessionserver.mojang.com/session/minecraft/profile/%22;%0A    private final List%3CUUID%3E uuids;%0A%0A    public NameFetcher(List%3C
 UUID
+%3E
  uuid
+s) %7B%0A        this.uuids = ImmutableList.copyOf(uuids);%0A    %7D%0A%0A    @Override%0A    public Map%3CUUID, String%3E call(
 ) th
@@ -1142,10 +1142,8 @@
 ows 
-IO
 Exce
@@ -1162,82 +1162,175 @@
     
-URLConnection connection = new URL(%22https://api.mojang.com/user/profiles/%22
+Map%3CUUID, String%3E uuidStringMap = new HashMap%3C%3E();%0A        for (UUID uuid : uuids) %7B%0A            HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL
  + u
@@ -1364,33 +1364,8 @@
  %22%22)
-.toLowerCase() + %22/names%22
 ).op
@@ -1392,56 +1392,95 @@
     
-String text = new String(ByteStreams.toByteArray
+    Map%3CString, String%3E response = RedisBungee.getGson().fromJson(new InputStreamReader
 (con
@@ -1508,34 +1508,9 @@
 m())
-);%0A        Type listType =
+,
  new
@@ -1524,25 +1524,45 @@
 ken%3C
-List
+Map
 %3CString
-%3E%3E() %7B
+, String%3E%3E() %7B%0A            
 %7D.ge
@@ -1568,16 +1568,17 @@
 etType()
+)
 ;%0A      
@@ -1583,61 +1583,447 @@
     
+   
-return RedisBungee.getGson().fromJson(text, listType)
+ String name = response.get(%22name%22);%0A            if (name == null) %7B%0A                continue;%0A            %7D%0A            String cause = response.get(%22cause%22);%0A            String errorMessage = response.get(%22errorMessage%22);%0A            if (cause != null && cause.length() %3E 0) %7B%0A                throw new IllegalStateException(errorMessage);%0A            %7D%0A            uuidStringMap.put(uuid, name);%0A        %7D%0A        return uuidStringMap
 ;%0A  

Revert to old method as the new method has changed