Fixed completable future not completable futuring

This commit is contained in:
Sollace 2018-08-22 16:12:21 +02:00
parent 3cc26b7cd1
commit a4f93686df

View file

@ -18,7 +18,6 @@ import com.voxelmodpack.hdskins.skins.MoreHttpResponses;
import com.voxelmodpack.hdskins.skins.NetClient;
import com.voxelmodpack.hdskins.skins.SkinServer;
import com.voxelmodpack.hdskins.skins.SkinUpload;
import com.voxelmodpack.hdskins.skins.SkinUploadResponse;
import java.io.Closeable;
import java.io.File;
@ -179,20 +178,15 @@ public class SkinUploader implements Closeable {
sendingSkin = true;
status = statusMsg;
return gateway.uploadSkin(mc.getSession(), new SkinUpload(skinType, localSkin.toURI(), skinMetadata))
.thenAccept(this::onUploadCompleted)
.exceptionally(this::onUploadFailure);
}
private void onUploadCompleted(SkinUploadResponse response) {
return gateway.uploadSkin(mc.getSession(), new SkinUpload(skinType, localSkin == null ? null : localSkin.toURI(), skinMetadata)).handle((response, throwable) -> {
if (throwable == null) {
LiteLoaderLogger.info("Upload completed with: %s", response);
sendingSkin = false;
setError(null);
} else {
setError(Throwables.getRootCause(throwable).toString());
}
private Void onUploadFailure(Throwable response) {
response = Throwables.getRootCause(response);
setError(response.toString());
return null;
});
}
public CompletableFuture<MoreHttpResponses> downloadSkin() {
@ -206,7 +200,10 @@ public class SkinUploader implements Closeable {
throttlingNeck = false;
offline = false;
remotePlayer.reloadRemoteSkin(this, this::onSetRemoteSkin).handle((a, throwable) -> {
remotePlayer.reloadRemoteSkin(this, (type, location, profileTexture) -> {
fetchingSkin = false;
listener.onSetRemoteSkin(type, location, profileTexture);
}).handle((a, throwable) -> {
fetchingSkin = false;
if (throwable != null) {
@ -224,13 +221,6 @@ public class SkinUploader implements Closeable {
});
}
private void onSetRemoteSkin(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) {
if (fetchingSkin) {
fetchingSkin = false;
listener.onSetRemoteSkin(type, location, profileTexture);
}
}
@Override
public void close() throws IOException {
localPlayer.releaseTextures();