package lel.flummi.skilloverlay.api; import net.minecraft.client.MinecraftClient; import java.io.InputStreamReader; import java.net.URL; import java.util.Timer; import java.util.TimerTask; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lel.flummi.skilloverlay.api.records.Profile; import lel.flummi.skilloverlay.api.records.Profile.Profiles.Member; import lel.flummi.skilloverlay.config.skilloverlayconfig; public class PlayerProfile { public static Member PROFILE; private static Timer timerTask; private static boolean timerSet; private static String apikey; private static String uuid; public static void init(Boolean timer) { if (timer && !timerSet) { timerTask = new Timer("Timer"); timerTask.scheduleAtFixedRate(new TimerTask() { public void run() { PlayerProfile.updateProfile(); } }, 0, 1000L * 60L * 3); timerSet = true; } uuid = MinecraftClient.getInstance().getSession().getUuidOrNull().toString().replace("-", ""); apikey = skilloverlayconfig.get().general.apiKey; PlayerProfile.updateProfile(); } public static void updateProfile() { String apiurl = "https://api.hypixel.net/skyblock/profiles?key=" + apikey + "&uuid=" + uuid; if (apiurl.length() == 0) return; try { URL url = new URL(apiurl); InputStreamReader reader = new InputStreamReader(url.openStream()); Gson gson = new GsonBuilder() .serializeNulls() .create(); Profile profile = gson.fromJson(reader, Profile.class); if (profile != null) { profile.profiles().removeIf(p -> !p.selected()); PROFILE = profile.profiles().get(0).members().get(uuid); } else { System.out.println("leer uff"); } } catch (Exception e) { e.printStackTrace(); } return; } }