Search in sources :

Example 6 with PlushieSession

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;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession) JsonObject(com.google.gson.JsonObject)

Example 7 with PlushieSession

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);
    }
}
Also used : DownloadJsonObjectCallable(riskyken.armourersWorkshop.common.library.global.DownloadUtils.DownloadJsonObjectCallable) PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession) JsonObject(com.google.gson.JsonObject) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 8 with PlushieSession

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);
}
Also used : DownloadJsonObjectCallable(riskyken.armourersWorkshop.common.library.global.DownloadUtils.DownloadJsonObjectCallable) PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession) JsonObject(com.google.gson.JsonObject) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 9 with PlushieSession

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;
    }
}
Also used : PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession)

Aggregations

PlushieSession (riskyken.armourersWorkshop.common.library.global.auth.PlushieSession)9 JsonObject (com.google.gson.JsonObject)5 GameProfile (com.mojang.authlib.GameProfile)4 GuiGlobalLibrary (riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)4 DownloadJsonObjectCallable (riskyken.armourersWorkshop.common.library.global.DownloadUtils.DownloadJsonObjectCallable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 MessageClientGuiButton (riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiButton)1