use of com.github.steveice10.mc.auth.data.GameProfile.Property in project DragonProxy by DragonetMC.
the class SkinFetcher method getPlayerProfile.
private PlayerProfile getPlayerProfile(GameProfile gameProfile) {
try {
return profilesCache.get(gameProfile.getId(), () -> {
Property property = getProfileProperty(gameProfile.getId());
System.out.println(property.toString());
Skin skin = Skin.DEFAULT_SKIN_STEVE;
if (gameProfile.getTextures().containsKey(GameProfile.TextureType.SKIN)) {
System.out.println(gameProfile.getTexture(GameProfile.TextureType.SKIN).getURL());
System.out.println(Skin.getModelFromJava(gameProfile.getTexture(GameProfile.TextureType.SKIN).getModel()));
skin = new Skin(new URL(gameProfile.getTexture(GameProfile.TextureType.SKIN).getURL()), Skin.getModelFromJava(gameProfile.getTexture(GameProfile.TextureType.SKIN).getModel()));
}
if (gameProfile.getTextures().containsKey(GameProfile.TextureType.CAPE))
skin.setCape(skin.new Cape(new URL(gameProfile.getTexture(GameProfile.TextureType.CAPE).getURL())));
PlayerProfile profile = new PlayerProfile(gameProfile.getId(), property, skin);
if (property != null) {
// profilesCache.put(gameProfile.getId(), profile);
return profile;
}
return null;
});
} catch (CacheLoader.InvalidCacheLoadException | ExecutionException ex) {
return null;
}
}
use of com.github.steveice10.mc.auth.data.GameProfile.Property in project DragonProxy by DragonetMC.
the class SkinFetcher method getProfileProperty.
// This will be cached by Guava
private Property getProfileProperty(UUID Uuid) throws IOException, ParseException {
final URL url = new URL(PROFILE_URL + Uuid.toString().replace("-", "") + "?unsigned=false");
final HttpURLConnection URLConnection = (HttpURLConnection) url.openConnection();
System.out.println("ResponseCode : " + URLConnection.getResponseCode() + " UUID : " + Uuid.toString());
Property property = null;
if (URLConnection.getResponseCode() == 200 || URLConnection.getResponseCode() == 204) {
JsonObject jsonObject = gson.fromJson(new InputStreamReader(URLConnection.getInputStream(), Charsets.UTF_8), JsonObject.class);
JsonArray jsonArray = jsonObject.get("properties").getAsJsonArray();
for (int i = 0; i < jsonArray.size(); i++) {
JsonObject rawProperty = jsonArray.get(i).getAsJsonObject();
String name = rawProperty.get("name").getAsString();
String value = rawProperty.get("value").getAsString();
String signature = rawProperty.get("signature").getAsString();
property = new Property(name, value, signature);
}
System.out.println("Fetch Profile Property : " + Uuid + " OK!");
}
return property;
}
Aggregations