Search in sources :

Example 1 with MinecraftProfilePropertiesResponse

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

the class YggdrasilMinecraftSessionService method fillGameProfile.

protected GameProfile fillGameProfile(GameProfile profile, boolean requireSecure) {
    try {
        URL url = HttpAuthenticationService.constantURL("https://sessionserver.mojang.com/session/minecraft/profile/" + UUIDTypeAdapter.fromUUID(profile.getId()));
        url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
        MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) this.getAuthenticationService().makeRequest(url, (Object) null, MinecraftProfilePropertiesResponse.class);
        if (response == null) {
            LOGGER.debug("Couldn't fetch profile properties for " + profile + " as the profile does not exist");
            return profile;
        } else {
            GameProfile result = new GameProfile(response.getId(), response.getName());
            result.getProperties().putAll(response.getProperties());
            profile.getProperties().putAll(response.getProperties());
            LOGGER.debug("Successfully fetched profile properties for " + profile);
            return result;
        }
    } catch (AuthenticationException var6) {
        LOGGER.warn("Couldn't look up profile properties for " + profile, var6);
        return profile;
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) AuthenticationException(com.mojang.authlib.exceptions.AuthenticationException) MinecraftProfilePropertiesResponse(com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse) JSONObject(org.json.JSONObject)

Example 2 with MinecraftProfilePropertiesResponse

use of com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse in project Citizens2 by CitizensDev.

the class NMSImpl method fillProfileProperties.

@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
    if (Bukkit.isPrimaryThread())
        throw new IllegalStateException("NMS.fillProfileProperties cannot be invoked from the main thread.");
    MinecraftSessionService sessionService = ((CraftServer) Bukkit.getServer()).getServer().ay();
    if (!(sessionService instanceof YggdrasilMinecraftSessionService)) {
        return sessionService.fillProfileProperties(profile, requireSecure);
    }
    YggdrasilAuthenticationService auth = ((YggdrasilMinecraftSessionService) sessionService).getAuthenticationService();
    URL url = HttpAuthenticationService.constantURL(getAuthServerBaseUrl() + UUIDTypeAdapter.fromUUID(profile.getId()));
    url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
    MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(auth, url, null, MinecraftProfilePropertiesResponse.class);
    if (response == null)
        return profile;
    GameProfile result = new GameProfile(response.getId(), response.getName());
    result.getProperties().putAll(response.getProperties());
    profile.getProperties().putAll(response.getProperties());
    return result;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) MinecraftProfilePropertiesResponse(com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) MinecraftSessionService(com.mojang.authlib.minecraft.MinecraftSessionService) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) URL(java.net.URL)

Example 3 with MinecraftProfilePropertiesResponse

use of com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse in project Citizens2 by CitizensDev.

the class NMSImpl method fillProfileProperties.

@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
    if (Bukkit.isPrimaryThread())
        throw new IllegalStateException("NMS.fillProfileProperties cannot be invoked from the main thread.");
    MinecraftSessionService sessionService = ((CraftServer) Bukkit.getServer()).getServer().aD();
    if (!(sessionService instanceof YggdrasilMinecraftSessionService)) {
        return sessionService.fillProfileProperties(profile, requireSecure);
    }
    YggdrasilAuthenticationService auth = ((YggdrasilMinecraftSessionService) sessionService).getAuthenticationService();
    URL url = HttpAuthenticationService.constantURL(getAuthServerBaseUrl() + UUIDTypeAdapter.fromUUID(profile.getId()));
    url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
    MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(auth, url, null, MinecraftProfilePropertiesResponse.class);
    if (response == null)
        return profile;
    GameProfile result = new GameProfile(response.getId(), response.getName());
    result.getProperties().putAll(response.getProperties());
    profile.getProperties().putAll(response.getProperties());
    return result;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) MinecraftProfilePropertiesResponse(com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) MinecraftSessionService(com.mojang.authlib.minecraft.MinecraftSessionService) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) URL(java.net.URL)

Example 4 with MinecraftProfilePropertiesResponse

use of com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse in project Citizens2 by CitizensDev.

the class NMSImpl method fillProfileProperties.

@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
    if (Bukkit.isPrimaryThread())
        throw new IllegalStateException("NMS.fillProfileProperties cannot be invoked from the main thread.");
    MinecraftSessionService sessionService = ((CraftServer) Bukkit.getServer()).getServer().az();
    if (!(sessionService instanceof YggdrasilMinecraftSessionService)) {
        return sessionService.fillProfileProperties(profile, requireSecure);
    }
    YggdrasilAuthenticationService auth = ((YggdrasilMinecraftSessionService) sessionService).getAuthenticationService();
    URL url = HttpAuthenticationService.constantURL(getAuthServerBaseUrl() + UUIDTypeAdapter.fromUUID(profile.getId()));
    url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
    MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(auth, url, null, MinecraftProfilePropertiesResponse.class);
    if (response == null)
        return profile;
    GameProfile result = new GameProfile(response.getId(), response.getName());
    result.getProperties().putAll(response.getProperties());
    profile.getProperties().putAll(response.getProperties());
    return result;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) MinecraftProfilePropertiesResponse(com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) MinecraftSessionService(com.mojang.authlib.minecraft.MinecraftSessionService) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) URL(java.net.URL)

Example 5 with MinecraftProfilePropertiesResponse

use of com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse in project Citizens2 by CitizensDev.

the class NMSImpl method fillProfileProperties.

@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
    if (Bukkit.isPrimaryThread())
        throw new IllegalStateException("NMS.fillProfileProperties cannot be invoked from the main thread.");
    MinecraftSessionService sessionService = ((CraftServer) Bukkit.getServer()).getServer().az();
    if (!(sessionService instanceof YggdrasilMinecraftSessionService)) {
        return sessionService.fillProfileProperties(profile, requireSecure);
    }
    YggdrasilAuthenticationService auth = ((YggdrasilMinecraftSessionService) sessionService).getAuthenticationService();
    URL url = HttpAuthenticationService.constantURL(getAuthServerBaseUrl() + UUIDTypeAdapter.fromUUID(profile.getId()));
    url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
    MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(auth, url, null, MinecraftProfilePropertiesResponse.class);
    if (response == null)
        return profile;
    GameProfile result = new GameProfile(response.getId(), response.getName());
    result.getProperties().putAll(response.getProperties());
    profile.getProperties().putAll(response.getProperties());
    return result;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) MinecraftProfilePropertiesResponse(com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) YggdrasilMinecraftSessionService(com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService) MinecraftSessionService(com.mojang.authlib.minecraft.MinecraftSessionService) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) URL(java.net.URL)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)5 MinecraftProfilePropertiesResponse (com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse)5 MinecraftSessionService (com.mojang.authlib.minecraft.MinecraftSessionService)4 YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)4 YggdrasilMinecraftSessionService (com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService)4 URL (java.net.URL)4 AuthenticationException (com.mojang.authlib.exceptions.AuthenticationException)1 JSONObject (org.json.JSONObject)1