Search in sources :

Example 1 with ProfileSearchResultsResponse

use of com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse in project Krothium-Launcher by DarkLBP.

the class YggdrasilGameProfileRepository method findProfilesByNames.

public void findProfilesByNames(String[] names, Agent agent, ProfileLookupCallback callback) {
    HashSet criteria = Sets.newHashSet();
    String[] page = names;
    int i$ = names.length;
    for (int var19 = 0; var19 < i$; ++var19) {
        String var20 = page[var19];
        if (!Strings.isNullOrEmpty(var20)) {
            criteria.add(var20.toLowerCase());
        }
    }
    byte var211 = 0;
    Iterator var221 = Iterables.partition(criteria, ENTRIES_PER_PAGE).iterator();
    while (var221.hasNext()) {
        List var21 = (List) var221.next();
        int var22 = 0;
        while (true) {
            boolean failed = false;
            try {
                ProfileSearchResultsResponse var18 = (ProfileSearchResultsResponse) this.authenticationService.makeRequest(GET_PROFILESID, var21, ProfileSearchResultsResponse.class);
                var22 = 0;
                LOGGER.debug("Page {} returned {} results, parsing", new Object[] { Integer.valueOf(var211), Integer.valueOf(var18.getProfiles().length) });
                HashSet var23 = Sets.newHashSet(var21);
                GameProfile[] var24 = var18.getProfiles();
                int var25 = var24.length;
                for (int var26 = 0; var26 < var25; ++var26) {
                    GameProfile var27 = var24[var26];
                    System.out.println("Profile data from " + var27.getName() + " got from the Krothium API");
                    LOGGER.debug("Successfully looked up profile {}", new Object[] { var27 });
                    var23.remove(var27.getName().toLowerCase());
                    callback.onProfileLookupSucceeded(var27);
                }
                Iterator var261 = Iterables.partition(var23, ENTRIES_PER_PAGE).iterator();
                while (var261.hasNext()) {
                    List var30 = (List) var261.next();
                    var18 = (ProfileSearchResultsResponse) this.authenticationService.makeRequest(GET_PROFILESID_MOJANG, var30, ProfileSearchResultsResponse.class);
                    var22 = 0;
                    LOGGER.debug("Page {} returned {} results, parsing", new Object[] { Integer.valueOf(var211), Integer.valueOf(var18.getProfiles().length) });
                    var23 = Sets.newHashSet(var21);
                    var24 = var18.getProfiles();
                    var25 = var24.length;
                    for (int var26 = 0; var26 < var25; ++var26) {
                        GameProfile var27 = var24[var26];
                        System.out.println("Profile data from " + var27.getName() + " got from the Mojang API");
                        LOGGER.debug("Successfully looked up profile {}", new Object[] { var27 });
                        var23.remove(var27.getName().toLowerCase());
                        callback.onProfileLookupSucceeded(var27);
                    }
                    var261 = var23.iterator();
                    while (var261.hasNext()) {
                        String var271 = (String) var261.next();
                        LOGGER.debug("Couldn\'t find profile {}", new Object[] { var271 });
                        callback.onProfileLookupFailed(new GameProfile(null, var271), new ProfileNotFoundException("Server did not find the requested profile"));
                    }
                    try {
                        Thread.sleep(DELAY_BETWEEN_PAGES);
                    } catch (InterruptedException var191) {
                        ;
                    }
                }
                try {
                    Thread.sleep(DELAY_BETWEEN_PAGES);
                } catch (InterruptedException var191) {
                    ;
                }
            } catch (AuthenticationException var201) {
                AuthenticationException e = var201;
                ++var22;
                if (var22 == MAX_FAIL_COUNT) {
                    Iterator ignored = var21.iterator();
                    while (ignored.hasNext()) {
                        String name = (String) ignored.next();
                        LOGGER.debug("Couldn\'t find profile {} because of a server error", new Object[] { name });
                        callback.onProfileLookupFailed(new GameProfile(null, name), e);
                    }
                } else {
                    try {
                        Thread.sleep(DELAY_BETWEEN_FAILURES);
                    } catch (InterruptedException var181) {
                        ;
                    }
                    failed = true;
                }
            }
            if (!failed) {
                break;
            }
        }
    }
}
Also used : AuthenticationException(com.mojang.authlib.exceptions.AuthenticationException) ProfileSearchResultsResponse(com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse) GameProfile(com.mojang.authlib.GameProfile) Iterator(java.util.Iterator) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)1 AuthenticationException (com.mojang.authlib.exceptions.AuthenticationException)1 ProfileSearchResultsResponse (com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1