use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.
the class GuiGlobalLibraryPanelSkinInfo method authenticateUser.
private boolean authenticateUser() {
GameProfile gameProfile = mc.thePlayer.getGameProfile();
PlushieSession plushieSession = PlushieAuth.PLUSHIE_SESSION;
if (!plushieSession.isAuthenticated()) {
JsonObject jsonObject = PlushieAuth.updateAccessToken(gameProfile.getName(), gameProfile.getId().toString());
plushieSession.authenticate(jsonObject);
}
if (!plushieSession.isAuthenticated()) {
ModLogger.log(Level.ERROR, "Authentication failed.");
return false;
}
return true;
}
use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.
the class GuiGlobalLibraryPanelSkinInfo method setSkinLike.
private void setSkinLike(boolean like) {
if (authenticateUser()) {
PlushieSession plushieSession = PlushieAuth.PLUSHIE_SESSION;
GuiGlobalLibrary globalLibrary = (GuiGlobalLibrary) parent;
int userId = plushieSession.getServerId();
String accessToken = plushieSession.getAccessToken();
int skinId = skinJson.get("id").getAsInt();
String url = "https://plushie.moe/armourers_workshop/user-skin-action.php";
url += "?userId=" + String.valueOf(userId);
url += "&accessToken=" + accessToken;
if (like) {
url += "&action=like";
} else {
url += "&action=unlike";
}
url += "&skinId=" + String.valueOf(skinId);
taskDoLiked = new FutureTask<JsonObject>(new DownloadJsonObjectCallable(url));
((GuiGlobalLibrary) parent).jsonDownloadExecutor.execute(taskDoLiked);
}
}
use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.
the class GuiGlobalLibraryPanelSkinInfo method checkIfLiked.
private void checkIfLiked() {
PlushieSession plushieSession = PlushieAuth.PLUSHIE_SESSION;
GuiGlobalLibrary globalLibrary = (GuiGlobalLibrary) parent;
int userId = plushieSession.getServerId();
String accessToken = "";
int skinId = skinJson.get("id").getAsInt();
String url = SKIN_ACTION_URL;
url += "?userId=" + String.valueOf(userId);
url += "&accessToken=" + accessToken;
url += "&action=hasLike";
url += "&skinId=" + String.valueOf(skinId);
taskCheckIfLiked = new FutureTask<JsonObject>(new DownloadJsonObjectCallable(url));
((GuiGlobalLibrary) parent).jsonDownloadExecutor.execute(taskCheckIfLiked);
}
use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.
the class GuiGlobalLibraryPanelHeader method betaCheckUpdate.
private void betaCheckUpdate() {
boolean inBeta = PlushieAuth.isRemoteUser();
boolean doneBetaCheck = PlushieAuth.doneRemoteUserCheck();
PlushieSession session = PlushieAuth.PLUSHIE_SESSION;
// iconButtonFavourites.visible = inBeta;
if (session.hasServerId()) {
iconButtonMyFiles.visible = inBeta;
iconButtonUploadSkin.visible = inBeta;
iconButtonUploadSkin.enabled = true;
if (session.getPermission_group_id() == 255) {
iconButtonUploadSkin.enabled = false;
}
} else {
iconButtonMyFiles.visible = false;
iconButtonUploadSkin.visible = false;
}
if (doneBetaCheck) {
iconButtonJoinBeta.visible = !inBeta;
} else {
iconButtonJoinBeta.visible = false;
}
}
Aggregations