Make Mojang SessionServer Configurable (#499)

This commit is contained in:
Corey Shupe 2021-10-19 04:11:04 -04:00 committed by GitHub
parent b6bce86eca
commit 11d0f82b86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,7 @@ import java.util.Arrays;
import java.util.UUID;
public class EncryptionResponsePacket implements ClientPreplayPacket {
private static final String MOJANG_AUTH_URL = System.getProperty("minestom.auth.url", "https://sessionserver.mojang.com/session/minecraft/hasJoined").concat("?username=%s&serverId=%s");
private static final Gson GSON = new Gson();
private byte[] sharedSecret;
private byte[] verifyToken;
@ -64,9 +65,7 @@ public class EncryptionResponsePacket implements ClientPreplayPacket {
final String serverId = new BigInteger(digestedData).toString(16);
final String username = URLEncoder.encode(loginUsername, StandardCharsets.UTF_8);
final String url = "https://sessionserver.mojang.com/session/minecraft/hasJoined?"
+ "username=" + username + "&"
+ "serverId=" + serverId;
final String url = String.format(MOJANG_AUTH_URL, username, serverId);
// TODO: Add ability to add ip query tag. See: https://wiki.vg/Protocol_Encryption#Authentication
final HttpClient client = HttpClient.newHttpClient();