Only url should be used as cache key

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-11-08 08:49:25 +01:00
parent 5959b37600
commit 519c1cb937

View File

@ -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);