fix bedrock invalid server pinging
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m36s

This commit is contained in:
Lee 2024-04-17 20:51:48 +01:00
parent 5fbab2c0ec
commit cbfaa867a9
2 changed files with 5 additions and 5 deletions

@ -1,5 +1,6 @@
package xyz.mcutils.backend.common;
import com.google.gson.JsonObject;
import lombok.experimental.UtilityClass;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;

@ -10,10 +10,7 @@ import xyz.mcutils.backend.model.server.BedrockMinecraftServer;
import xyz.mcutils.backend.service.pinger.MinecraftServerPinger;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.net.*;
/**
* The {@link MinecraftServerPinger} for pinging
@ -61,6 +58,8 @@ public final class BedrockMinecraftServerPinger implements MinecraftServerPinger
throw new BadRequestException("Unknown hostname: %s".formatted(hostname));
} else if (ex instanceof SocketTimeoutException) {
throw new ResourceNotFoundException(ex);
} else if (ex instanceof SocketException) {
throw new BadRequestException("An error occurred pinging %s:%s".formatted(hostname, port));
}
log.error("An error occurred pinging %s:%s:".formatted(hostname, port), ex);
}