4141import java .net .HttpURLConnection ;
4242import java .net .URL ;
4343import java .nio .charset .StandardCharsets ;
44+ import java .util .Locale ;
45+ import java .util .Objects ;
4446import java .util .Set ;
4547import java .util .UUID ;
4648import java .util .concurrent .CompletableFuture ;
@@ -64,7 +66,7 @@ final class MojangProfileResolver implements ProfileResolver {
6466 private static final Pattern UUID_NO_DASH_PATTERN = Pattern .compile ("-" , Pattern .LITERAL );
6567 private static final Pattern UUID_DASHER_PATTERN = Pattern .compile ("(\\ w{8})(\\ w{4})(\\ w{4})(\\ w{4})(\\ w{12})" );
6668
67- private static final String NAME_TO_UUID_ENDPOINT = "https://api.mojang .com/users/profiles/minecraft /%s" ;
69+ private static final String NAME_TO_UUID_ENDPOINT = "https://api.minecraftservices .com/minecraft/profile/lookup/name /%s" ;
6870 private static final String UUID_TO_PROFILE_ENDPOINT = "https://sessionserver.mojang.com/session/minecraft/profile/%s?unsigned=false" ;
6971
7072 private static @ NotNull JsonObject makeRequest (@ NotNull String endpoint ) throws IOException {
@@ -136,7 +138,8 @@ final class MojangProfileResolver implements ProfileResolver {
136138 UUID uniqueId = profile .uniqueId ();
137139 if (uniqueId == null ) {
138140 // this will give us either a valid object or throw an exception
139- JsonObject responseData = makeRequest (String .format (NAME_TO_UUID_ENDPOINT , profile .name ()));
141+ String name = Objects .requireNonNull (profile .name (), "either profile name or uuid must be given" );
142+ JsonObject responseData = makeRequest (String .format (NAME_TO_UUID_ENDPOINT , name .toLowerCase (Locale .ROOT )));
140143 String rawUniqueId = responseData .get ("id" ).getAsString ();
141144
142145 // insert dashes into the unique id string we get to parse it
0 commit comments