/**
 * 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.gson.Gson;
import com.google.gson.reflect.TypeToken;

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) {
        URLConnection connection;
        try {
            connection = new URL("https://api.mojang.com/user/profiles/"
                    + uuid.toString().replace("-", "").toLowerCase() + "/names"
            ).openConnection();
            String text = new Scanner(connection.getInputStream()).useDelimiter("\\Z").next();
            Type listType = new TypeToken<List<String>>() {
            }.getType();
            List<String> list = new Gson().fromJson(text, listType);
            return list;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
@@ -329,17 +329,16 @@
 .util;%0A%0A
-%0A
 import c
@@ -351,17 +351,29 @@
 gle.
-gson.Gson
+common.io.ByteStreams
 ;%0Aim
@@ -411,16 +411,76 @@
 peToken;
+%0Aimport com.imaginarycode.minecraft.redisbungee.RedisBungee;
 %0A%0Aimport
@@ -693,16 +693,35 @@
 ID uuid)
+ throws IOException
  %7B%0A     
@@ -741,46 +741,8 @@
 ion 
-connection;%0A        try %7B%0A            
 conn
@@ -801,28 +801,8 @@
 es/%22
-%0A                   
  + u
@@ -857,29 +857,16 @@
 %22/names%22
-%0A            
 ).openCo
@@ -885,20 +885,16 @@
         
-  
-  
 String t
@@ -908,76 +908,69 @@
 ew S
-canner(connection.getInputStream()).useDelimiter(%22%5C%5CZ%22).next();%0A    
+tring(ByteStreams.toByteArray(connection.getInputStream()));%0A
     
@@ -1020,29 +1020,16 @@
 ng%3E%3E() %7B
-%0A            
 %7D.getTyp
@@ -1045,36 +1045,30 @@
     
-    List%3CString%3E list = new 
+return RedisBungee.get
 Gson
@@ -1100,131 +1100,8 @@
 e);%0A
-            return list;%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        return null;%0A
     

Allow RedisBungee to give the console an IOException instead of a unhelpful exception + NPE combo.