Search in sources :

Example 1 with PlushieSession

use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelSkinEdit 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 2 with PlushieSession

use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelSkinEdit method deleteSkin.

public void deleteSkin() {
    PlushieSession plushieSession = PlushieAuth.PLUSHIE_SESSION;
    GuiGlobalLibrary globalLibrary = (GuiGlobalLibrary) parent;
    int userId = plushieSession.getServerId();
    String accessToken = plushieSession.getAccessToken();
    int skinId = skinJson.get("id").getAsInt();
    taskSkinEdit = GlobalSkinLibraryUtils.deleteSkin(globalLibrary.jsonDownloadExecutor, userId, accessToken, skinId);
}
Also used : PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 3 with PlushieSession

use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelUpload method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == buttonUpload) {
        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;
        }
        MessageClientGuiButton message = new MessageClientGuiButton((byte) 0);
        PacketHandler.networkWrapper.sendToServer(message);
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession) JsonObject(com.google.gson.JsonObject) MessageClientGuiButton(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiButton)

Example 4 with PlushieSession

use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelUpload method uploadSkin.

public void uploadSkin(Skin skin) {
    GameProfile gameProfile = mc.thePlayer.getGameProfile();
    PlushieSession plushieSession = PlushieAuth.PLUSHIE_SESSION;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    SkinIOUtils.saveSkinToStream(outputStream, skin);
    byte[] fileBytes = outputStream.toByteArray();
    IOUtils.closeQuietly(outputStream);
    taskSkinUpload = SkinUploader.uploadSkin(fileBytes, textName.getText().trim(), Integer.toString(plushieSession.getServerId()), textDescription.getText().trim(), plushieSession.getAccessToken());
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 5 with PlushieSession

use of riskyken.armourersWorkshop.common.library.global.auth.PlushieSession in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelSkinEdit method updateSkin.

public void updateSkin() {
    PlushieSession plushieSession = PlushieAuth.PLUSHIE_SESSION;
    GuiGlobalLibrary globalLibrary = (GuiGlobalLibrary) parent;
    int userId = plushieSession.getServerId();
    String accessToken = plushieSession.getAccessToken();
    int skinId = skinJson.get("id").getAsInt();
    String name = textName.getText().trim();
    String description = textDescription.getText().trim();
    taskSkinEdit = GlobalSkinLibraryUtils.editSkin(globalLibrary.uploadExecutor, userId, accessToken, skinId, name, description);
}
Also used : PlushieSession(riskyken.armourersWorkshop.common.library.global.auth.PlushieSession) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

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