Search in sources :

Example 1 with YggdrasilMinecraftSessionService

use of com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService 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 2 with YggdrasilMinecraftSessionService

use of com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService 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 3 with YggdrasilMinecraftSessionService

use of com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService 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 4 with YggdrasilMinecraftSessionService

use of com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService 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)4 MinecraftSessionService (com.mojang.authlib.minecraft.MinecraftSessionService)4 YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)4 YggdrasilMinecraftSessionService (com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService)4 MinecraftProfilePropertiesResponse (com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse)4 URL (java.net.URL)4