Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit ff6d5dd

Browse files
committed
fix crash when unauthenticated
thanks to WindVertex for finding this - tweak image sharing
1 parent 4a77b40 commit ff6d5dd

File tree

9 files changed

+14
-11
lines changed

9 files changed

+14
-11
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void uploadImage(File file) {
5858

5959
public ImageInstance downloadImage(String url) {
6060
ImageData data = download(url);
61-
if (!data.name().isEmpty()) {
61+
if (data != ImageData.EMPTY) {
6262
try {
6363
return new ImageInstance(NativeImage.read(new ByteArrayInputStream(data.data())), data.name());
6464
} catch (IOException ignored) {

1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void uploadImage(File file) {
6161

6262
public ImageInstance downloadImage(String url) {
6363
ImageData data = download(url);
64-
if (!data.name().isEmpty()) {
64+
if (data != ImageData.EMPTY) {
6565
try {
6666
return new ImageInstance(NativeImage.read(new ByteArrayInputStream(data.data())), data.name());
6767
} catch (IOException ignored) {

1.21.4/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void uploadImage(File file) {
6060

6161
public ImageInstance downloadImage(String url) {
6262
ImageData data = download(url);
63-
if (!data.name().isEmpty()) {
63+
if (data != ImageData.EMPTY) {
6464
try {
6565
return new ImageInstance(NativeImage.read(new ByteArrayInputStream(data.data())), data.name());
6666
} catch (IOException ignored) {

1.21/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void uploadImage(File file) {
6161

6262
public ImageInstance downloadImage(String url) {
6363
ImageData data = download(url);
64-
if (!data.name().isEmpty()) {
64+
if (data != ImageData.EMPTY) {
6565
try {
6666
return new ImageInstance(NativeImage.read(new ByteArrayInputStream(data.data())), data.name());
6767
} catch (IOException ignored) {

1.8.9/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void doAction() {
6767

6868
public ImageInstance downloadImage(String url) {
6969
ImageData data = download(url);
70-
if (!data.name().isEmpty()) {
70+
if (data != ImageData.EMPTY) {
7171
try {
7272
return new ImageInstance(ImageIO.read(new ByteArrayInputStream(data.data())), data.name());
7373
} catch (IOException ignored) {

common/src/main/java/io/github/axolotlclient/api/API.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ public CompletableFuture<Response> delete(Request request) {
195195
}
196196

197197
private CompletableFuture<Response> request(Request request, String method) {
198+
if (!getApiOptions().enabled.get()) {
199+
return CompletableFuture.completedFuture(Response.builder().status(0).body("{\"description\":\"Integration disabled!\"}").build());
200+
}
198201
if (!getApiOptions().privacyAccepted.get().isAccepted()) {
199202
return CompletableFuture.completedFuture(Response.CLIENT_ERROR);
200203
}
@@ -208,9 +211,6 @@ private CompletableFuture<Response> request(Request request, String method) {
208211

209212
private CompletableFuture<Response> request(URI url, Map<String, ?> payload, byte[] rawBody, String method, Map<String, String> headers) {
210213
return CompletableFuture.supplyAsync(() -> {
211-
if (!getApiOptions().enabled.get()) {
212-
return Response.builder().status(0).body("{\"description\":\"Integration disabled!\"}").build();
213-
}
214214
try {
215215
logDetailed("Starting request to " + method + " " + url);
216216

common/src/main/java/io/github/axolotlclient/api/requests/UserRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class UserRequest {
5050

5151
public static boolean getOnline(String uuid) {
5252

53-
if (uuid == null) {
53+
if (uuid == null || !API.getInstance().isAuthenticated()) {
5454
return false;
5555
}
5656

common/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageNetworking.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.concurrent.CompletableFuture;
3030

3131
import io.github.axolotlclient.api.API;
32+
import io.github.axolotlclient.api.Constants;
3233
import io.github.axolotlclient.api.Request;
3334

3435
public abstract class ImageNetworking {
@@ -51,6 +52,9 @@ protected CompletableFuture<String> upload(String name, byte[] data) {
5152
}
5253

5354
protected ImageData download(String url) {
55+
if (url.contains("/") && !url.startsWith(Constants.API_URL)) {
56+
return ImageData.EMPTY;
57+
}
5458
if (url.endsWith("/raw")) {
5559
url = url.substring(0, url.length() - 4);
5660
}
@@ -68,6 +72,5 @@ protected ImageData download(String url) {
6872

6973
public record ImageData(String name, byte[] data) {
7074
public static final ImageData EMPTY = new ImageData("", new byte[0]);
71-
7275
}
7376
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.parallel=true
66
axolotlclient.modules.all=true
77

88
# Mod Properties
9-
version=3.1.0-beta.36
9+
version=3.1.0-beta.37
1010

1111
maven_group=io.github.axolotlclient
1212

0 commit comments

Comments
 (0)