Java Code Examples for com.github.steveice10.mc.auth.data.GameProfile#Property

The following examples show how to use com.github.steveice10.mc.auth.data.GameProfile#Property . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkinUtils.java    From Geyser with MIT License 5 votes vote down vote up
/**
 * Generate the GameProfileData from the given GameProfile
 *
 * @param profile GameProfile to build the GameProfileData from
 * @return The built GameProfileData
 */
public static GameProfileData from(GameProfile profile) {
    // Fallback to the offline mode of working it out
    boolean isAlex = ((profile.getId().hashCode() % 2) == 1);

    try {
        GameProfile.Property skinProperty = profile.getProperty("textures");

        JsonNode skinObject = new ObjectMapper().readTree(new String(Base64.getDecoder().decode(skinProperty.getValue()), StandardCharsets.UTF_8));
        JsonNode textures = skinObject.get("textures");

        JsonNode skinTexture = textures.get("SKIN");
        String skinUrl = skinTexture.get("url").asText();

        isAlex = skinTexture.has("metadata");

        String capeUrl = null;
        if (textures.has("CAPE")) {
            JsonNode capeTexture = textures.get("CAPE");
            capeUrl = capeTexture.get("url").asText();
        }

        return new GameProfileData(skinUrl, capeUrl, isAlex);
    } catch (Exception exception) {
        if (GeyserConnector.getInstance().getAuthType() != AuthType.OFFLINE) {
            GeyserConnector.getInstance().getLogger().debug("Got invalid texture data for " + profile.getName() + " " + exception.getMessage());
        }
        // return default skin with default cape when texture data is invalid
        return new GameProfileData((isAlex ? SkinProvider.EMPTY_SKIN_ALEX.getTextureUrl() : SkinProvider.EMPTY_SKIN.getTextureUrl()), SkinProvider.EMPTY_CAPE.getTextureUrl(), isAlex);
    }
}
 
Example 2
Source File: AuthenticationService.java    From Visage with MIT License 2 votes vote down vote up
/**
 * Gets the properties of the user logged in with the service.
 *
 * @return The user's properties.
 */
public List<GameProfile.Property> getProperties() {
    return this.isLoggedIn() ? new ArrayList<GameProfile.Property>(this.properties) : Collections.<GameProfile.Property>emptyList();
}
 
Example 3
Source File: AuthenticationService.java    From MCAuthLib with MIT License 2 votes vote down vote up
/**
 * Gets the properties of the user logged in with the service.
 *
 * @return The user's properties.
 */
public List<GameProfile.Property> getProperties() {
    return Collections.unmodifiableList(this.properties);
}