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;
}
}
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();
}
}
}
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);
}
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);
}
}
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);
}
Aggregations