use of com.mojang.authlib.HttpAuthenticationService in project DirtMultiversion by DirtPowered.
the class GameProfileFetcher method fetchBlocking.
private static GameProfile fetchBlocking(String username) throws ExecutionException, InterruptedException {
HttpAuthenticationService authenticationService = new YggdrasilAuthenticationService(Proxy.NO_PROXY);
MinecraftSessionService sessionService = authenticationService.createMinecraftSessionService();
GameProfileRepository service = authenticationService.createProfileRepository();
CompletableFuture<GameProfile> completableFuture = new CompletableFuture<>();
service.findProfilesByNames(new String[] { username }, Agent.MINECRAFT, new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile gameProfile) {
sessionService.fillProfileProperties(gameProfile, true);
completableFuture.complete(gameProfile);
}
@Override
public void onProfileLookupFailed(GameProfile gameProfile, Exception e) {
Logger.warn("unable to fetch profile for {}, e: {}", username, e.getMessage());
GameProfile offlineProfile = createOfflineProfile(username);
completableFuture.complete(offlineProfile);
}
});
return completableFuture.get();
}
Aggregations