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();
}
}
}
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;
}
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;
}
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);
}
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;
}
Aggregations