Reformat for clarity

This commit is contained in:
Sollace 2018-07-21 16:47:02 +02:00
parent 6a2de216f9
commit bbff6ceaab

View file

@ -11,6 +11,7 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.server.SkinUploadResponse;
import com.voxelmodpack.hdskins.upload.FileDropListener; import com.voxelmodpack.hdskins.upload.FileDropListener;
import com.voxelmodpack.hdskins.upload.ThreadOpenFilePNG; import com.voxelmodpack.hdskins.upload.ThreadOpenFilePNG;
@ -539,14 +540,18 @@ public class GuiSkins extends GuiScreen {
return number != 0 && (number & number - 1) == 0; return number != 0 && (number & number - 1) == 0;
} }
//TODO: Garggling marbles
private void punchServer(String uploadMsg, @Nullable URI path) { private void punchServer(String uploadMsg, @Nullable URI path) {
uploadingSkin = true; uploadingSkin = true;
skinUploadMessage = I18n.format(uploadMsg); skinUploadMessage = I18n.format(uploadMsg);
// TODO: This looks too much like the "fetch(method, url, headers).then(...then(..).then(...)).then(...).catch(...).then(...).then(...)...etc" hell.
HDSkinManager.INSTANCE.getGatewayServer() HDSkinManager.INSTANCE.getGatewayServer()
.uploadSkin(mc.getSession(), path, textureType, getMetadata()) .uploadSkin(mc.getSession(), path, textureType, getMetadata())
.thenAccept(response -> { .thenAccept(this::onUploadComplete)
.exceptionally(this::onUploadFailed);
}
private void onUploadComplete(SkinUploadResponse response) {
LiteLoaderLogger.info("Upload completed with: %s", response); LiteLoaderLogger.info("Upload completed with: %s", response);
uploadingSkin = false; uploadingSkin = false;
if (!response.isSuccess()) { if (!response.isSuccess()) {
@ -554,13 +559,14 @@ public class GuiSkins extends GuiScreen {
} else { } else {
pendingRemoteSkinRefresh = true; pendingRemoteSkinRefresh = true;
} }
}).exceptionally(t -> { }
private Void onUploadFailed(Throwable t) {
LogManager.getLogger().warn("Upload failed", t); LogManager.getLogger().warn("Upload failed", t);
setUploadError(t.toString()); setUploadError(t.toString());
uploadingSkin = false; uploadingSkin = false;
return null; return null;
});
} }
private Map<String, String> getMetadata() { private Map<String, String> getMetadata() {