Search in sources :

Example 6 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary in project Armourers-Workshop by RiskyKen.

the class ClientProxy method receivedSkinFromLibrary.

@Override
public void receivedSkinFromLibrary(String fileName, String filePath, Skin skin, SendType sendType) {
    switch(sendType) {
        case LIBRARY_SAVE:
            SkinIOUtils.saveSkinFromFileName(filePath, fileName + SkinIOUtils.SKIN_FILE_EXTENSION, skin);
            ArmourersWorkshop.proxy.libraryManager.addFileToListType(new LibraryFile(fileName, filePath, skin.getSkinType()), LibraryFileType.LOCAL, null);
            break;
        case GLOBAL_UPLOAD:
            GuiScreen screen = Minecraft.getMinecraft().currentScreen;
            if (screen instanceof GuiGlobalLibrary) {
                ((GuiGlobalLibrary) screen).gotSkinFromServer(skin);
            }
            break;
    }
}
Also used : GuiScreen(net.minecraft.client.gui.GuiScreen) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 7 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary in project Armourers-Workshop by RiskyKen.

the class GuiGlobalLibraryPanelSkinEdit method update.

@Override
public void update() {
    super.update();
    buttonUpdate.enabled = false;
    if (!StringUtils.isNullOrEmpty(textName.getText())) {
        buttonUpdate.enabled = true;
    }
    firstTick = false;
    if (taskSkinEdit != null && taskSkinEdit.isDone()) {
        try {
            JsonObject json = taskSkinEdit.get();
            taskSkinEdit = null;
            if (json != null) {
                if (json.has("valid") & json.has("action")) {
                    String action = json.get("action").getAsString();
                    boolean valid = json.get("valid").getAsBoolean();
                    if (action.equals("user-skin-edit")) {
                        ((GuiGlobalLibrary) parent).panelHome.updateSkinPanels();
                        ((GuiGlobalLibrary) parent).switchScreen(returnScreen);
                    } else if (action.equals("user-skin-delete")) {
                        ((GuiGlobalLibrary) parent).switchScreen(returnScreen);
                    } else {
                        ModLogger.log(Level.WARN, "Server send unknown action: " + action);
                    }
                } else {
                    ModLogger.log(Level.ERROR, "Server returned invalid responce.");
                }
            } else {
                ModLogger.log(Level.ERROR, "Server returned invalid responce.");
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) ExecutionException(java.util.concurrent.ExecutionException) GuiGlobalLibrary(riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)

Example 8 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary 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)

Example 9 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary 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 10 with GuiGlobalLibrary

use of riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary 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)

Aggregations

GuiGlobalLibrary (riskyken.armourersWorkshop.client.gui.globallibrary.GuiGlobalLibrary)15 JsonObject (com.google.gson.JsonObject)4 PlushieSession (riskyken.armourersWorkshop.common.library.global.auth.PlushieSession)4 GuiButtonExt (cpw.mods.fml.client.config.GuiButtonExt)3 ExecutionException (java.util.concurrent.ExecutionException)2 DownloadJsonObjectCallable (riskyken.armourersWorkshop.common.library.global.DownloadUtils.DownloadJsonObjectCallable)2 PlushieUser (riskyken.armourersWorkshop.common.library.global.PlushieUser)2 GameProfile (com.mojang.authlib.GameProfile)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiControlSkinPanel (riskyken.armourersWorkshop.client.gui.controls.GuiControlSkinPanel)1 SkinIcon (riskyken.armourersWorkshop.client.gui.controls.GuiControlSkinPanel.SkinIcon)1 GuiIconButton (riskyken.armourersWorkshop.client.gui.controls.GuiIconButton)1 GuiLabeledTextField (riskyken.armourersWorkshop.client.gui.controls.GuiLabeledTextField)1 SlotHidable (riskyken.armourersWorkshop.common.inventory.slot.SlotHidable)1 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)1