Search in sources :

Example 6 with YggdrasilAuthenticationService

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

use of com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService 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

YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)7 MinecraftSessionService (com.mojang.authlib.minecraft.MinecraftSessionService)5 GameProfile (com.mojang.authlib.GameProfile)4 YggdrasilMinecraftSessionService (com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService)4 MinecraftProfilePropertiesResponse (com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse)4 URL (java.net.URL)4 AuthenticationException (com.mojang.authlib.exceptions.AuthenticationException)2 YggdrasilUserAuthentication (com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication)2 Stage (com.google.inject.Stage)1 GameProfileRepository (com.mojang.authlib.GameProfileRepository)1 AuthenticationUnavailableException (com.mojang.authlib.exceptions.AuthenticationUnavailableException)1 File (java.io.File)1 OptionSet (joptsimple.OptionSet)1 DedicatedServer (net.minecraft.server.dedicated.DedicatedServer)1 PlayerProfileCache (net.minecraft.server.management.PlayerProfileCache)1 Session (net.minecraft.util.Session)1 SpongeModule (org.spongepowered.common.inject.SpongeModule)1 SpongeVanillaModule (org.spongepowered.server.inject.SpongeVanillaModule)1 MetadataContainer (org.spongepowered.server.plugin.MetadataContainer)1