diff --git a/LaunchServer/source/texture/AuthlibInjectorTextureProvider.java b/LaunchServer/source/texture/AuthlibInjectorTextureProvider.java index 951d245..e29b96e 100644 --- a/LaunchServer/source/texture/AuthlibInjectorTextureProvider.java +++ b/LaunchServer/source/texture/AuthlibInjectorTextureProvider.java @@ -26,12 +26,12 @@ @Override public synchronized Texture getSkinTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, urlApiInjector + "/api/profiles/minecraft", urlApiInjector + "/sessionserver/session/minecraft/profile/", "Authlib-Injector").skin; + return cacheTextureProvider.getCached(uuid, username, urlApiInjector + "/sessionserver/session/minecraft/profile/", "Authlib-Injector").skin; } @Override public synchronized Texture getCloakTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, urlApiInjector + "/api/profiles/minecraft", urlApiInjector + "/sessionserver/session/minecraft/profile/", "Authlib-Injector").cloak; + return cacheTextureProvider.getCached(uuid, username, urlApiInjector + "/sessionserver/session/minecraft/profile/", "Authlib-Injector").cloak; } } diff --git a/LaunchServer/source/texture/AuthlibTextureProvider.java b/LaunchServer/source/texture/AuthlibTextureProvider.java index 0cafe82..2a57a88 100644 --- a/LaunchServer/source/texture/AuthlibTextureProvider.java +++ b/LaunchServer/source/texture/AuthlibTextureProvider.java @@ -9,14 +9,12 @@ public class AuthlibTextureProvider extends TextureProvider { // Instance - private final String setUuidURL; private final String setProfileURL; protected CacheTextureProvider cacheTextureProvider = new CacheTextureProvider(); public AuthlibTextureProvider(BlockConfigEntry block) { super(block); - setUuidURL = block.getEntryValue("usersURL", StringConfigEntry.class); setProfileURL = block.getEntryValue("profileURL", StringConfigEntry.class); } @@ -29,12 +27,12 @@ @Override public synchronized Texture getSkinTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, setUuidURL, setProfileURL, "Authlib").skin; + return cacheTextureProvider.getCached(uuid, username, setProfileURL, "Authlib").skin; } @Override public synchronized Texture getCloakTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, setUuidURL, setProfileURL, "Authlib").cloak; + return cacheTextureProvider.getCached(uuid, username, setProfileURL, "Authlib").cloak; } } diff --git a/LaunchServer/source/texture/CacheTextureProvider.java b/LaunchServer/source/texture/CacheTextureProvider.java index 4242517..3e1f2c3 100644 --- a/LaunchServer/source/texture/CacheTextureProvider.java +++ b/LaunchServer/source/texture/CacheTextureProvider.java @@ -29,9 +29,12 @@ // Instance private final Map cache = new HashMap<>(1024); - protected CacheDataTexture getCached(UUID uuid, String username, String in_usersURL, String in_profileURL, String serviceName) + // Since November 2020, Mojang stopped supporting the timestamp parameter. + // If a timestamp is provided, it is silently ignored and the current uuid is returned. Please remind them to fix this here: + // https://bugs.mojang.com/browse/WEB-3367 + protected CacheDataTexture getCached(UUID uuid, String username, String in_profileURL, String serviceName) { - CacheDataTexture result = cache.get(username); + CacheDataTexture result = cache.get(uuid); // Have cached result? if (result != null && System.currentTimeMillis() < result.until) @@ -45,16 +48,8 @@ try { - URL uuidURL = new URL(in_usersURL + IOHelper.urlEncode(username)); - JsonObject uuidResponse = HTTPRequestHelper.makeAuthlibRequest(uuidURL, null, serviceName); - if (uuidResponse == null) - { - throw new IllegalArgumentException("Empty UUID response"); - } - String uuidResolved = uuidResponse.get("id").asString(); - // Obtain player profile - URL profileURL = new URL(in_profileURL + IOHelper.urlEncode(serviceName.equals("ElyBy") ? username : uuidResolved )); // Как я это не хотел делать... + URL profileURL = new URL(in_profileURL + IOHelper.urlEncode(serviceName.equals("ElyBy") ? username : uuid.toString())); // Как я это не хотел делать... JsonObject profileResponse = HTTPRequestHelper.makeAuthlibRequest(profileURL, null, serviceName); if (profileResponse == null) { diff --git a/LaunchServer/source/texture/ElyByTextureProvider.java b/LaunchServer/source/texture/ElyByTextureProvider.java index 8bad47d..c533b8b 100644 --- a/LaunchServer/source/texture/ElyByTextureProvider.java +++ b/LaunchServer/source/texture/ElyByTextureProvider.java @@ -22,12 +22,12 @@ @Override public synchronized Texture getSkinTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, "https://authserver.ely.by/api/users/profiles/minecraft/", "http://skinsystem.ely.by/profile/", "ElyBy").skin; + return cacheTextureProvider.getCached(uuid, "https://authserver.ely.by/api/users/profiles/minecraft/", "http://skinsystem.ely.by/profile/", "ElyBy").skin; } @Override public synchronized Texture getCloakTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, "https://authserver.ely.by/api/users/profiles/minecraft/", "http://skinsystem.ely.by/profile/", "ElyBy").cloak; + return cacheTextureProvider.getCached(uuid, "https://authserver.ely.by/api/users/profiles/minecraft/", "http://skinsystem.ely.by/profile/", "ElyBy").cloak; } } diff --git a/LaunchServer/source/texture/MineSocialTextureProvider.java b/LaunchServer/source/texture/MineSocialTextureProvider.java index bbe6584..059b970 100644 --- a/LaunchServer/source/texture/MineSocialTextureProvider.java +++ b/LaunchServer/source/texture/MineSocialTextureProvider.java @@ -22,12 +22,12 @@ @Override public synchronized Texture getSkinTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, "https://api.minesocial.net/users/profiles/minecraft/", "https://sessionserver.minesocial.net/session/minecraft/profile/", "MineSocial").skin; + return cacheTextureProvider.getCached(uuid, username, "https://sessionserver.minesocial.net/session/minecraft/profile/", "MineSocial").skin; } @Override public synchronized Texture getCloakTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, "https://api.minesocial.net/users/profiles/minecraft/", "https://sessionserver.minesocial.net/session/minecraft/profile/", "MineSocial").cloak; + return cacheTextureProvider.getCached(uuid, username, "https://sessionserver.minesocial.net/session/minecraft/profile/", "MineSocial").cloak; } } diff --git a/LaunchServer/source/texture/MojangTextureProvider.java b/LaunchServer/source/texture/MojangTextureProvider.java index 0289e68..0f1991d 100644 --- a/LaunchServer/source/texture/MojangTextureProvider.java +++ b/LaunchServer/source/texture/MojangTextureProvider.java @@ -23,12 +23,12 @@ @Override public synchronized Texture getSkinTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, "https://api.mojang.com/users/profiles/minecraft/", "https://sessionserver.mojang.com/session/minecraft/profile/", "Mojang").skin; + return cacheTextureProvider.getCached(uuid, username, "https://sessionserver.mojang.com/session/minecraft/profile/", "Mojang").skin; } @Override public synchronized Texture getCloakTexture(UUID uuid, String username) { - return cacheTextureProvider.getCached(uuid, username, "https://api.mojang.com/users/profiles/minecraft/", "https://sessionserver.mojang.com/session/minecraft/profile/", "Mojang").cloak; + return cacheTextureProvider.getCached(uuid, username, "https://sessionserver.mojang.com/session/minecraft/profile/", "Mojang").cloak; } }