use of kml.auth.user.User in project Krothium-Launcher by DarkLBP.
the class MainFX method fetchAds.
/**
* Fetches any advertisement available for the logged user
*/
private void fetchAds() {
User user = kernel.getAuthentication().getSelectedUser();
if (user.getType() != UserType.MOJANG) {
String profileID = user.getSelectedProfile();
String adsCheck = "https://mc.krothium.com/ads.php?profileID=" + profileID;
String response = Utils.readURL(adsCheck);
if (!response.isEmpty()) {
String[] chunks = response.split(":");
String firstChunk = Utils.fromBase64(chunks[0]);
urlPrefix = firstChunk == null ? "" : firstChunk;
if (chunks.length == 2) {
String secondChunk = Utils.fromBase64(response.split(":")[1]);
String adsURL = secondChunk == null ? "" : secondChunk;
kernel.getBrowser().loadWebsite(adsURL);
kernel.getBrowser().show(mainScene);
}
console.print("Ads loaded.");
} else {
console.print("Ads info not available.");
}
} else {
console.print("Ads not available for Mojang user.");
}
}
Aggregations