Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.yarotu.nick.utils.skin;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.Scanner;
- import java.util.logging.Level;
- import org.bukkit.Bukkit;
- import org.json.simple.JSONArray;
- import org.json.simple.JSONObject;
- import org.json.simple.parser.JSONParser;
- public class Skin {
- String uuid;
- String name;
- String value;
- String signatur;
- public Skin(String uuid){
- this.uuid = uuid;
- load();
- }
- private void load() {
- try {
- URL url = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
- URLConnection urlConnection = url.openConnection();
- urlConnection.setUseCaches(false);
- urlConnection.setDefaultUseCaches(false);
- urlConnection.addRequestProperty("Cache-Control", "no-chache, no-store, must-revalidate");
- urlConnection.addRequestProperty("Pragma", "no-chache");
- Scanner scanner = new Scanner(urlConnection.getInputStream(), "UTF-8");
- String json = scanner.useDelimiter("\\A").next();
- scanner.close();
- JSONParser parser = new JSONParser();
- Object object = parser.parse(json);
- JSONArray properties = (JSONArray) ((JSONObject) object).get("propertis");
- for(int i = 0; i < properties.size(); i++) {
- try {
- JSONObject property = (JSONObject) properties.get(i);
- String name = (String) property.get("name");
- String value = (String) property.get("value");
- String signature = property.containsKey("signature") ? (String) property.get("signature") : null;
- this.name = name;
- this.value = value;
- this.signatur = signature;
- } catch (Exception e) {
- Bukkit.getLogger().log(Level.WARNING, "Fehler bei der Auth property", e);
- }
- }
- } catch (Exception e) {
- System.out.println("Fehler bei der Skin.java");
- e.printStackTrace();
- }
- }
- public String getSkinvalue() {
- return value;
- }
- public String getSkinName() {
- return name;
- }
- public String getSkinSignatur() {
- return signatur;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement