2014-04-20 05:12:28 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2015-01-09 14:44:03 +00:00
|
|
|
import com.google.common.io.ByteStreams;
|
2014-04-20 05:12:28 +00:00
|
|
|
import com.google.gson.reflect.TypeToken;
|
2014-12-27 23:30:26 +00:00
|
|
|
import com.imaginarycode.minecraft.redisbungee.RedisBungee;
|
2014-04-20 05:12:28 +00:00
|
|
|
|
2015-01-09 14:44:03 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.lang.reflect.Type;
|
2014-04-20 05:12:28 +00:00
|
|
|
import java.net.URL;
|
2015-01-09 14:44:03 +00:00
|
|
|
import java.net.URLConnection;
|
|
|
|
import java.util.*;
|
2014-04-20 05:12:28 +00:00
|
|
|
|
2015-01-09 14:44:03 +00:00
|
|
|
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);
|
2014-04-20 05:12:28 +00:00
|
|
|
}
|
|
|
|
}
|