From 470118ac1c5897e7a5953bc32eb2c18dc32e8543 Mon Sep 17 00:00:00 2001 From: 1e99 Date: Mon, 16 Dec 2024 15:56:33 +0100 Subject: [PATCH] cleanup --- .../pixelchat/fabric/image/ImageUploader.java | 3 ++ .../pixelchat/fabric/image/ImageUploads.java | 50 ------------------- 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploader.java b/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploader.java index a3e211c..d0e386d 100644 --- a/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploader.java +++ b/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploader.java @@ -4,5 +4,8 @@ import java.nio.file.Path; public interface ImageUploader { + /** + * @return An URL to a downloadable PNG file + */ String upload(Path path) throws Throwable; } diff --git a/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploads.java b/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploads.java index c3bf045..be6a7c9 100644 --- a/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploads.java +++ b/mod-fabric/src/eu/e99/pixelchat/fabric/image/ImageUploads.java @@ -79,55 +79,5 @@ public class ImageUploads { } this.client.send(() -> bossBars.remove(bossBar.getUuid())); - - /*try { - this.minecraft.send(() -> bossBars.add(bossBar.getUuid(), bossBar)); - - // TODO: Report some sort of progress? - HttpRequest req = HttpRequest.newBuilder() - .POST(HttpRequest.BodyPublishers.ofFile(path)) - .uri(this.endpoint) - .build(); - - HttpResponse res = this.client.send( - req, - HttpResponse.BodyHandlers.ofString() - ); - if (res.statusCode() != 201) { - throw new RuntimeException(String.format("Failed to upload, expected status 201, got %d", res.statusCode())); - } - - this.minecraft.send(() -> { - // TODO: Are we actually playing? - if (this.minecraft.player == null) { - return; - } - - bossBar.setName(Text.translatable("pixelchat.upload_completed")); - bossBar.setPercent(1.0f); - bossBar.setColor(BossBar.Color.GREEN); - - String id = res.body(); - String url = String.format("%s", id); - - this.minecraft.inGameHud.getChatHud().addToMessageHistory(url); - this.minecraft.player.networkHandler.sendChatMessage(url); - }); - } catch (Throwable e) { - PixelChat.LOGGER.error("Upload failed", e); - - this.minecraft.send(() -> { - bossBar.setName(Text.translatable("pixelchat.upload_failed")); - bossBar.setPercent(1.0f); - bossBar.setColor(BossBar.Color.RED); - }); - } finally { - try { - Thread.sleep(5000); - } catch (InterruptedException ignored) { - } - - this.minecraft.send(() -> bossBars.remove(bossBar.getUuid())); - }*/ } }