/**
 * 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);
    }
}
@@ -351,29 +351,22 @@
 gle.
-common.io.ByteStreams
+gson.JsonArray
 ;%0Aim
@@ -390,85 +390,53 @@
 son.
-reflect.TypeToken;%0Aimport com.imaginarycode.minecraft.redisbungee.RedisBungee
+JsonObject;%0Aimport com.google.gson.JsonParser
 ;%0A%0Ai
@@ -478,25 +478,15 @@
 ava.
-lang.reflect.Type
+net.URL
 ;%0Aim
@@ -494,32 +494,42 @@
 ort java.net.URL
+Connection
 ;%0Aimport java.ne
@@ -526,33 +526,79 @@
 rt java.
-net.URLConnection
+util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Scanner
 ;%0Aimport
@@ -608,17 +608,20 @@
 va.util.
-*
+UUID
 ;%0A%0Apubli
@@ -642,16 +642,74 @@
 tcher %7B%0A
+    private static JsonParser parser = new JsonParser();%0A%0A
     publ
@@ -765,27 +765,8 @@
 uid)
- throws IOException
  %7B%0A 
@@ -786,16 +786,54 @@
 nection 
+connection;%0A        try %7B%0A            
 connecti
@@ -884,16 +884,36 @@
 ofiles/%22
+%0A                   
  + uuid.
@@ -964,16 +964,29 @@
 %22/names%22
+%0A            
 ).openCo
@@ -1005,16 +1005,20 @@
         
+   
+ 
 String t
@@ -1032,37 +1032,14 @@
 ew S
-tring(ByteStreams.toByteArray
+canner
 (con
@@ -1063,16 +1063,42 @@
 tream())
+.useDelimiter(%22%5C%5CZ%22).next(
 );%0A     
@@ -1104,129 +1104,382 @@
     
+  
-Type listType = new TypeToken%3CList%3CString%3E%3E() %7B%7D.getType();%0A        return RedisBungee.getGson().fromJson(text, listType)
+  JsonArray list = (JsonArray) parser.parse(text);%0A            List%3CString%3E names = new ArrayList%3C%3E();%0A            for (int i = 0; i %3C list.size(); i++) %7B%0A                names.add(((JsonObject) list.get(i)).get(%22name%22).getAsString());%0A            %7D%0A            return names;%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        return null
 ;%0A  

Use new-new method with a better ratelimit