refactor pixel chat uploader
This commit is contained in:
parent
bd12e1fbc9
commit
b1c33bfba1
2 changed files with 7 additions and 9 deletions
|
@ -19,8 +19,8 @@ public class PixelChat implements ClientModInitializer {
|
||||||
UPLOADS = new ImageUploads(
|
UPLOADS = new ImageUploads(
|
||||||
MinecraftClient.getInstance(),
|
MinecraftClient.getInstance(),
|
||||||
new ImageUploader[]{
|
new ImageUploader[]{
|
||||||
new PixelChatUploader("https", "pc.1e99.eu", 443),
|
new PixelChatUploader("https://pc.1e99.eu"),
|
||||||
new PixelChatUploader("https", "localhost", 443)
|
new PixelChatUploader("http://localhost:3000")
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.e99.pixelchat.fabric.image;
|
package eu.e99.pixelchat.fabric.image;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
|
@ -10,15 +9,14 @@ import java.nio.file.Path;
|
||||||
public class PixelChatUploader implements ImageUploader {
|
public class PixelChatUploader implements ImageUploader {
|
||||||
|
|
||||||
private final HttpClient client;
|
private final HttpClient client;
|
||||||
private final String scheme;
|
|
||||||
private final String host;
|
private final String host;
|
||||||
private final int port;
|
|
||||||
|
|
||||||
public PixelChatUploader(String scheme, String host, int port) {
|
/**
|
||||||
|
* @param host A valid URI to the server. Must not end with a slash. Valid examples are: {@code https://pc.1e99.eu} or {@code http://localhost:3000}.
|
||||||
|
*/
|
||||||
|
public PixelChatUploader(String host) {
|
||||||
this.client = HttpClient.newHttpClient();
|
this.client = HttpClient.newHttpClient();
|
||||||
this.scheme = scheme;
|
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.port = port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,6 +40,6 @@ public class PixelChatUploader implements ImageUploader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String url(String path) {
|
private String url(String path) {
|
||||||
return String.format("%s://%s:%d/%s", this.scheme, this.host, this.port, path);
|
return String.format("%s/%s", this.host, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue