Search in sources :

Example 51 with Property

use of com.mojang.authlib.properties.Property in project Krothium-Launcher by DarkLBP.

the class YggdrasilMinecraftSessionService method getTextures.

public Map<Type, MinecraftProfileTexture> getTextures(GameProfile profile, boolean requireSecure) {
    Property textureProperty = (Property) Iterables.getFirst(profile.getProperties().get("textures"), (Object) null);
    if (textureProperty == null) {
        return fetchCustomTextures(profile, requireSecure);
    } else {
        MinecraftTexturesPayload result;
        try {
            String json = new String(Base64.decodeBase64(textureProperty.getValue()), Charsets.UTF_8);
            result = (MinecraftTexturesPayload) this.gson.fromJson(json, MinecraftTexturesPayload.class);
        } catch (JsonParseException var7) {
            LOGGER.error("Could not decode textures payload", var7);
            return new HashMap();
        }
        if (result != null && result.getTextures() != null) {
            Iterator var8 = result.getTextures().entrySet().iterator();
            Map.Entry entry;
            do {
                if (!var8.hasNext()) {
                    return result.getTextures();
                }
                entry = (Map.Entry) var8.next();
            } while (isWhitelistedDomain(((MinecraftProfileTexture) entry.getValue()).getUrl()));
            LOGGER.error("Textures payload has been tampered with (non-whitelisted domain)");
            return new HashMap();
        } else {
            return new HashMap();
        }
    }
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) MinecraftTexturesPayload(com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload) JSONObject(org.json.JSONObject) JsonParseException(com.google.gson.JsonParseException) Property(com.mojang.authlib.properties.Property) HashMap(java.util.HashMap) Map(java.util.Map)

Example 52 with Property

use of com.mojang.authlib.properties.Property in project askyblock by tastybento.

the class SkullBlock method getPlayerProfile.

// Credits: dori99xd
public static GameProfile getPlayerProfile(String textureValue, String textureSignature, String ownerUUID, String ownerName) {
    // Create a new GameProfile with .schematic informations or with fake informations
    GameProfile newSkinProfile = new GameProfile(ownerUUID == null ? UUID.randomUUID() : UUID.fromString(ownerUUID), ownerName == null ? getRandomString(16) : null);
    // Insert textures properties
    newSkinProfile.getProperties().put("textures", new Property("textures", textureValue, textureSignature));
    return newSkinProfile;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property)

Example 53 with Property

use of com.mojang.authlib.properties.Property in project acidisland by tastybento.

the class SkullBlock method getNonPlayerProfile.

// Credits: dori99xd
public static GameProfile getNonPlayerProfile(String textureValue, String ownerUUID, String ownerName) {
    // Create a new GameProfile with .schematic informations or with fake informations
    GameProfile newSkinProfile = new GameProfile(ownerUUID == null ? UUID.randomUUID() : UUID.fromString(ownerUUID), ownerName == null ? getRandomString(16) : null);
    // Insert textures properties
    newSkinProfile.getProperties().put("textures", new Property("textures", textureValue));
    return newSkinProfile;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property)

Example 54 with Property

use of com.mojang.authlib.properties.Property in project Citizens2 by CitizensDev.

the class Skin method setNPCTexture.

private static void setNPCTexture(SkinnableEntity entity, Property skinProperty) {
    GameProfile profile = entity.getProfile();
    // don't set property if already set since this sometimes causes
    // packet errors that disconnect the client.
    Property current = Iterables.getFirst(profile.getProperties().get("textures"), null);
    if (current != null && current.getValue().equals(skinProperty.getValue()) && (current.getSignature() != null && current.getSignature().equals(skinProperty.getSignature()))) {
        return;
    }
    // ensure client does not crash due to duplicate properties.
    profile.getProperties().removeAll("textures");
    profile.getProperties().put("textures", skinProperty);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property)

Example 55 with Property

use of com.mojang.authlib.properties.Property in project Citizens2 by CitizensDev.

the class Skin method apply.

/**
 * Apply the skin data to the specified skinnable entity.
 *
 * <p>
 * If invoked before the skin data is ready, the skin is retrieved and the skin is automatically applied to the
 * entity at a later time.
 * </p>
 *
 * @param entity
 *            The skinnable entity.
 *
 * @return True if skin was applied, false if the data is being retrieved.
 */
public boolean apply(SkinnableEntity entity) {
    Preconditions.checkNotNull(entity);
    NPC npc = entity.getNPC();
    // Use npc cached skin if available.
    // If npc requires latest skin, cache is used for faster
    // availability until the latest skin can be loaded.
    String cachedName = npc.data().get(CACHED_SKIN_UUID_NAME_METADATA);
    String texture = npc.data().get(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA, "cache");
    if (this.skinName.equals(cachedName) && !texture.equals("cache")) {
        Property localData = new Property("textures", texture, npc.data().<String>get(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN_METADATA));
        setNPCTexture(entity, localData);
        // check if NPC prefers to use cached skin over the latest skin.
        if (entity.getNPC().data().has("player-skin-use-latest")) {
            entity.getNPC().data().remove("player-skin-use-latest");
        }
        if (!entity.getNPC().data().get(NPC.PLAYER_SKIN_USE_LATEST, Setting.NPC_SKIN_USE_LATEST.asBoolean())) {
            // cache preferred
            return true;
        }
    }
    if (!hasSkinData()) {
        if (hasFetched) {
            return true;
        } else {
            if (!fetching) {
                fetch();
            }
            pending.put(entity, null);
            return false;
        }
    }
    setNPCSkinData(entity, skinName, skinId, skinData);
    return true;
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) Property(com.mojang.authlib.properties.Property)

Aggregations

Property (com.mojang.authlib.properties.Property)65 GameProfile (com.mojang.authlib.GameProfile)61 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)16 UUID (java.util.UUID)15 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)12 BigInteger (java.math.BigInteger)7 MessageDigest (java.security.MessageDigest)7 Scoreboard (org.bukkit.scoreboard.Scoreboard)7 Team (org.bukkit.scoreboard.Team)7 MinecraftServer (net.minecraft.server.MinecraftServer)3 com.denizenscript.denizen.nms.util.jnbt (com.denizenscript.denizen.nms.util.jnbt)2 IOException (java.io.IOException)2 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)2 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 SpaceRace (micdoodle8.mods.galacticraft.core.dimension.SpaceRace)2 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)2 EntityBuggy (micdoodle8.mods.galacticraft.core.entities.EntityBuggy)2