Fix not being able to ping all servers

This commit is contained in:
Braydon 2024-04-06 20:45:30 -04:00
parent e8daa7c904
commit 29577d8287

@ -149,10 +149,12 @@ public final class MojangService {
throw new InvalidMinecraftServerPlatform(); throw new InvalidMinecraftServerPlatform();
} }
InetSocketAddress address = DNSUtils.resolveSRV(hostname); // Resolve the SRV record InetSocketAddress address = DNSUtils.resolveSRV(hostname); // Resolve the SRV record
if (address == null) { // No address found int port = platform.getDefaultPort(); // Port to ping
throw new ResourceNotFoundException("No SRV record found for hostname: %s".formatted(hostname)); if (address != null) { // SRV was resolved, use the hostname and port
hostname = address.getHostName();
port = address.getPort();
} }
return platform.getPinger().ping(address.getHostName(), address.getPort()); // Ping the server and return with the response return platform.getPinger().ping(hostname, port); // Ping the server and return with the response
} }
/** /**