mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-26 14:08:02 +00:00
Remove cache, actually fix NameFetcher
This commit is contained in:
parent
e13a8de1d7
commit
5010670d95
@ -17,10 +17,7 @@ import java.net.URLConnection;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class NameFetcher {
|
public class NameFetcher {
|
||||||
private static Map<UUID, List<String>> cache = new HashMap<>();
|
|
||||||
|
|
||||||
public static List<String> nameHistoryFromUuid(UUID uuid) {
|
public static List<String> nameHistoryFromUuid(UUID uuid) {
|
||||||
if (cache.containsKey(uuid)) return cache.get(uuid);
|
|
||||||
URLConnection connection;
|
URLConnection connection;
|
||||||
try {
|
try {
|
||||||
connection = new URL("https://api.mojang.com/user/profiles/"
|
connection = new URL("https://api.mojang.com/user/profiles/"
|
||||||
@ -30,7 +27,6 @@ public class NameFetcher {
|
|||||||
Type listType = new TypeToken<List<String>>() {
|
Type listType = new TypeToken<List<String>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
List<String> list = new Gson().fromJson(text, listType);
|
List<String> list = new Gson().fromJson(text, listType);
|
||||||
cache.put(uuid, list);
|
|
||||||
return list;
|
return list;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -162,7 +162,7 @@ public final class UUIDTranslator {
|
|||||||
// That didn't work. Let's ask Mojang. This call may fail, because Mojang is insane.
|
// That didn't work. Let's ask Mojang. This call may fail, because Mojang is insane.
|
||||||
String name;
|
String name;
|
||||||
try {
|
try {
|
||||||
name = new NameFetcher(Collections.singletonList(player)).call().get(player);
|
name = NameFetcher.nameHistoryFromUuid(player).get(0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Unable to fetch name from Mojang for " + player, e);
|
plugin.getLogger().log(Level.SEVERE, "Unable to fetch name from Mojang for " + player, e);
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user