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,28 +540,33 @@ 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)
LiteLoaderLogger.info("Upload completed with: %s", response); .exceptionally(this::onUploadFailed);
uploadingSkin = false; }
if (!response.isSuccess()) {
setUploadError(response.getMessage());
} else {
pendingRemoteSkinRefresh = true;
}
}).exceptionally(t -> {
LogManager.getLogger().warn("Upload failed", t);
setUploadError(t.toString());
uploadingSkin = false;
return null; private void onUploadComplete(SkinUploadResponse response) {
}); LiteLoaderLogger.info("Upload completed with: %s", response);
uploadingSkin = false;
if (!response.isSuccess()) {
setUploadError(response.getMessage());
} else {
pendingRemoteSkinRefresh = true;
}
}
private Void onUploadFailed(Throwable t) {
LogManager.getLogger().warn("Upload failed", t);
setUploadError(t.toString());
uploadingSkin = false;
return null;
} }
private Map<String, String> getMetadata() { private Map<String, String> getMetadata() {