mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
Only url should be used as cache key
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
5959b37600
commit
519c1cb937
@ -26,18 +26,16 @@ public final class MojangUtils {
|
|||||||
|
|
||||||
@Blocking
|
@Blocking
|
||||||
public static @Nullable JsonObject fromUuid(@NotNull String uuid) {
|
public static @Nullable JsonObject fromUuid(@NotNull String uuid) {
|
||||||
final String url = String.format(FROM_UUID_URL, uuid);
|
return retrieve(String.format(FROM_UUID_URL, uuid));
|
||||||
return retrieve(url, uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Blocking
|
@Blocking
|
||||||
public static @Nullable JsonObject fromUsername(@NotNull String username) {
|
public static @Nullable JsonObject fromUsername(@NotNull String username) {
|
||||||
final String url = String.format(FROM_USERNAME_URL, username);
|
return retrieve(String.format(FROM_USERNAME_URL, username));
|
||||||
return retrieve(url, username);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @Nullable JsonObject retrieve(@NotNull String url, @NotNull String key) {
|
private static @Nullable JsonObject retrieve(@NotNull String url) {
|
||||||
return URL_CACHE.get(key, s -> {
|
return URL_CACHE.get(url, s -> {
|
||||||
try {
|
try {
|
||||||
// Retrieve from the rate-limited Mojang API
|
// Retrieve from the rate-limited Mojang API
|
||||||
final String response = URLUtils.getText(url);
|
final String response = URLUtils.getText(url);
|
||||||
|
Loading…
Reference in New Issue
Block a user