set skin minecraft entity player

Solutions on MaxInterview for set skin minecraft entity player by the best coders in the world

showing results for - "set skin minecraft entity player"
Raphael
06 Sep 2020
1public static boolean setSkin(GameProfile profile, UUID uuid) {
2    try {
3        HttpsURLConnection connection = (HttpsURLConnection) new URL(String.format("https://sessionserver.mojang.com/session/minecraft/profile/%s?unsigned=false", UUIDTypeAdapter.fromUUID(uuid))).openConnection();
4        if (connection.getResponseCode() == HttpsURLConnection.HTTP_OK) {
5            String reply = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
6            String skin = reply.split("\"value\":\"")[1].split("\"")[0];
7            String signature = reply.split("\"signature\":\"")[1].split("\"")[0];
8            profile.getProperties().put("textures", new Property("textures", skin, signature));
9            return true;
10        } else {
11            System.out.println("Connection could not be opened (Response code " + connection.getResponseCode() + ", " + connection.getResponseMessage() + ")");
12            return false;
13        }
14    } catch (IOException e) {
15        e.printStackTrace();
16        return false;
17    }
18}
19