From 29577d82874dfa82d2c29409bed1b4c8f712f8cc Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Sat, 6 Apr 2024 20:45:30 -0400 Subject: [PATCH] Fix not being able to ping all servers --- src/main/java/me/braydon/mc/service/MojangService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/braydon/mc/service/MojangService.java b/src/main/java/me/braydon/mc/service/MojangService.java index 00a4932..a05930e 100644 --- a/src/main/java/me/braydon/mc/service/MojangService.java +++ b/src/main/java/me/braydon/mc/service/MojangService.java @@ -149,10 +149,12 @@ public final class MojangService { throw new InvalidMinecraftServerPlatform(); } InetSocketAddress address = DNSUtils.resolveSRV(hostname); // Resolve the SRV record - if (address == null) { // No address found - throw new ResourceNotFoundException("No SRV record found for hostname: %s".formatted(hostname)); + int port = platform.getDefaultPort(); // Port to ping + 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 } /**