Search in sources :

Example 1 with HasJoinedMinecraftServerResponse

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

the class YggdrasilMinecraftSessionService method hasJoinedServer.

public GameProfile hasJoinedServer(GameProfile user, String serverId, InetAddress address) throws AuthenticationUnavailableException {
    Map<String, Object> arguments = new HashMap();
    arguments.put("username", user.getName());
    arguments.put("serverId", serverId);
    if (address != null) {
        arguments.put("ip", address.getHostAddress());
    }
    URL url = HttpAuthenticationService.concatenateURL(CHECK_URL, HttpAuthenticationService.buildQuery(arguments));
    try {
        HasJoinedMinecraftServerResponse response = (HasJoinedMinecraftServerResponse) this.getAuthenticationService().makeRequest(url, (Object) null, HasJoinedMinecraftServerResponse.class);
        if (response != null && response.getId() != null) {
            GameProfile result = new GameProfile(response.getId(), user.getName());
            if (response.getProperties() != null) {
                result.getProperties().putAll(response.getProperties());
            }
            return result;
        } else {
            return null;
        }
    } catch (AuthenticationUnavailableException var8) {
        throw var8;
    } catch (AuthenticationException var9) {
        return null;
    }
}
Also used : AuthenticationUnavailableException(com.mojang.authlib.exceptions.AuthenticationUnavailableException) HashMap(java.util.HashMap) HasJoinedMinecraftServerResponse(com.mojang.authlib.yggdrasil.response.HasJoinedMinecraftServerResponse) GameProfile(com.mojang.authlib.GameProfile) AuthenticationException(com.mojang.authlib.exceptions.AuthenticationException) JSONObject(org.json.JSONObject)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)1 AuthenticationException (com.mojang.authlib.exceptions.AuthenticationException)1 AuthenticationUnavailableException (com.mojang.authlib.exceptions.AuthenticationUnavailableException)1 HasJoinedMinecraftServerResponse (com.mojang.authlib.yggdrasil.response.HasJoinedMinecraftServerResponse)1 HashMap (java.util.HashMap)1 JSONObject (org.json.JSONObject)1