DNS records shouldnt be NonNull
All checks were successful
Deploy API / docker (17, 3.8.5) (push) Successful in 1m45s
All checks were successful
Deploy API / docker (17, 3.8.5) (push) Successful in 1m45s
This commit is contained in:
parent
52ff61c554
commit
2261bde6cb
@ -64,9 +64,9 @@ public class MinecraftServer {
|
||||
@EqualsAndHashCode.Include private final int port;
|
||||
|
||||
/**
|
||||
* The DNS records resolved for this server.
|
||||
* The DNS records resolved for this server, null if none.
|
||||
*/
|
||||
@NonNull private final DNSRecord[] records;
|
||||
private final DNSRecord[] records;
|
||||
|
||||
/**
|
||||
* The Geo location of this server, null if unknown.
|
||||
|
@ -55,7 +55,7 @@ public final class BedrockMinecraftServer extends MinecraftServer {
|
||||
@NonNull private final GameMode gamemode;
|
||||
|
||||
private BedrockMinecraftServer(@NonNull String id, @NonNull String hostname, String ip, int port, GeoLocation geo,
|
||||
@NonNull DNSRecord[] records, @NonNull Edition edition, @NonNull Version version,
|
||||
DNSRecord[] records, @NonNull Edition edition, @NonNull Version version,
|
||||
@NonNull Players players, @NonNull MOTD motd, @NonNull GameMode gamemode) {
|
||||
super(hostname, ip, port, records, geo, players, motd);
|
||||
this.id = id;
|
||||
@ -70,13 +70,12 @@ public final class BedrockMinecraftServer extends MinecraftServer {
|
||||
* @param hostname the hostname of the server
|
||||
* @param ip the IP address of the server
|
||||
* @param port the port of the server
|
||||
* @param records the DNS records of the server
|
||||
* @param records the DNS records of the server, if any
|
||||
* @param token the status token
|
||||
* @return the Bedrock Minecraft server
|
||||
*/
|
||||
@NonNull
|
||||
public static BedrockMinecraftServer create(@NonNull String hostname, String ip, int port,
|
||||
@NonNull DNSRecord[] records, @NonNull String token) {
|
||||
public static BedrockMinecraftServer create(@NonNull String hostname, String ip, int port, DNSRecord[] records, @NonNull String token) {
|
||||
String[] split = token.split(";"); // Split the token
|
||||
Edition edition = Edition.valueOf(split[0]);
|
||||
Version version = new Version(Integer.parseInt(split[2]), split[3]);
|
||||
|
@ -123,7 +123,7 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
||||
*/
|
||||
private boolean mojangBanned;
|
||||
|
||||
private JavaMinecraftServer(@NonNull String hostname, String ip, int port, @NonNull DNSRecord[] records, GeoLocation geo,
|
||||
private JavaMinecraftServer(@NonNull String hostname, String ip, int port, DNSRecord[] records, GeoLocation geo,
|
||||
@NonNull Version version, @NonNull Players players, @NonNull MOTD motd, Favicon favicon,
|
||||
String software, Plugin[] plugins, ModInfo modInfo, ForgeData forgeData, String world,
|
||||
boolean queryEnabled, boolean previewsChat, boolean enforcesSecureChat, boolean preventsChatReports,
|
||||
@ -149,13 +149,13 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
||||
* @param hostname the hostname of the server
|
||||
* @param ip the IP address of the server
|
||||
* @param port the port of the server
|
||||
* @param records the DNS records of the server
|
||||
* @param records the DNS records of the server, if any
|
||||
* @param statusToken the status token
|
||||
* @param challengeStatusToken the challenge status token, null if none
|
||||
* @return the Java Minecraft server
|
||||
*/
|
||||
@NonNull
|
||||
public static JavaMinecraftServer create(@NonNull String hostname, String ip, int port, @NonNull DNSRecord[] records,
|
||||
public static JavaMinecraftServer create(@NonNull String hostname, String ip, int port, DNSRecord[] records,
|
||||
@NonNull JavaServerStatusToken statusToken, JavaServerChallengeStatusToken challengeStatusToken) {
|
||||
String motdString = statusToken.getDescription() instanceof String ? (String) statusToken.getDescription() : null;
|
||||
if (motdString == null) { // Not a string motd, convert from Json
|
||||
|
@ -30,7 +30,6 @@ import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import lombok.*;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import me.braydon.mc.common.EnvironmentUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.codehaus.plexus.archiver.tar.TarGZipUnArchiver;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -438,9 +438,10 @@ public final class MojangService {
|
||||
throw new BadRequestException("Invalid port defined");
|
||||
}
|
||||
}
|
||||
String cacheKey = "%s-%s".formatted(platform.name(), lookupHostname.replace(":", "-"));
|
||||
|
||||
// Check the cache for the server
|
||||
Optional<CachedMinecraftServer> cached = minecraftServerCache.findById("%s-%s".formatted(platform.name(), lookupHostname));
|
||||
Optional<CachedMinecraftServer> cached = minecraftServerCache.findById(cacheKey);
|
||||
if (cached.isPresent()) { // Respond with the cache if present
|
||||
log.info("Found server in cache: {}", hostname);
|
||||
return cached.get();
|
||||
@ -466,7 +467,11 @@ public final class MojangService {
|
||||
CityResponse geo = null; // The server's Geo location
|
||||
try {
|
||||
log.info("Looking up Geo location data for {}...", ip);
|
||||
geo = maxMindService.lookupCity(InetAddress.getByName(ip)); // Get the Geo location
|
||||
|
||||
InetAddress address = InetAddress.getByName(ip);
|
||||
if (!address.isAnyLocalAddress()) { // Get the Geo location
|
||||
geo = maxMindService.lookupCity(address);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("Failed looking up Geo location data for %s:".formatted(ip), ex);
|
||||
}
|
||||
@ -481,7 +486,7 @@ public final class MojangService {
|
||||
}
|
||||
|
||||
CachedMinecraftServer minecraftServer = new CachedMinecraftServer(
|
||||
platform.name() + "-" + lookupHostname, response, System.currentTimeMillis()
|
||||
cacheKey, response, System.currentTimeMillis()
|
||||
);
|
||||
|
||||
// Get the blocked status of the Java server
|
||||
|
Loading…
Reference in New Issue
Block a user