Always use HTTPS when communicating with the Mojang api
This commit is contained in:
parent
2e439a5b18
commit
4e00381e50
@ -2,6 +2,7 @@ package net.frozenorb.apiv3.util;
|
||||
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import io.vertx.core.http.HttpClient;
|
||||
import io.vertx.core.http.HttpClientOptions;
|
||||
import io.vertx.core.json.DecodeException;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@ -13,10 +14,11 @@ import java.util.UUID;
|
||||
@UtilityClass
|
||||
public class MojangUtils {
|
||||
|
||||
private static final HttpClient httpClient = APIv3.getVertxInstance().createHttpClient();
|
||||
private static final HttpClient httpsClient = APIv3.getVertxInstance().createHttpClient(new HttpClientOptions().setSsl(true).setTrustAll(true));
|
||||
|
||||
public static void getName(UUID id, SingleResultCallback<String> callback) {
|
||||
httpClient.get("sessionserver.mojang.com", "/session/minecraft/profile/" + id.toString().replace("-", ""), (response) -> {
|
||||
System.out.println("sessionserver.mojang.com/session/minecraft/profile/" + id.toString().replace("-", ""));
|
||||
httpsClient.get(443, "sessionserver.mojang.com", "/session/minecraft/profile/" + id.toString().replace("-", ""), (response) -> {
|
||||
response.bodyHandler((body) -> {
|
||||
try {
|
||||
JsonObject bodyJson = new JsonObject(body.toString());
|
||||
@ -28,7 +30,7 @@ public class MojangUtils {
|
||||
callback.onResult(name, null);
|
||||
}
|
||||
} catch (DecodeException ex) {
|
||||
callback.onResult(null, new RuntimeException(body.toString(), ex));
|
||||
callback.onResult(null, ex);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user