From 2df4a7978cfe2c25cf816e6249b7d39aa3500c9a Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Wed, 10 Apr 2024 09:40:19 -0400 Subject: [PATCH] Small fixes --- .../me/braydon/mc/model/server/JavaMinecraftServer.java | 4 ++-- src/main/java/me/braydon/mc/service/MojangService.java | 8 +++++--- .../mc/service/pinger/impl/JavaMinecraftServerPinger.java | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java b/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java index 743f017..1d5b257 100644 --- a/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java +++ b/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java @@ -238,9 +238,9 @@ public final class JavaMinecraftServer extends MinecraftServer { @AllArgsConstructor @Getter @ToString private static class Mod { /** - * The id of this mod. + * The name of this mod. */ - @NonNull @SerializedName("modid") private final String id; + @NonNull @SerializedName("modid") private final String name; /** * The version of this mod. diff --git a/src/main/java/me/braydon/mc/service/MojangService.java b/src/main/java/me/braydon/mc/service/MojangService.java index 550ee6d..a2fd925 100644 --- a/src/main/java/me/braydon/mc/service/MojangService.java +++ b/src/main/java/me/braydon/mc/service/MojangService.java @@ -400,10 +400,12 @@ public final class MojangService { } // Build our server model, cache it, and then return it + MinecraftServer response = platform.getPinger().ping(hostname, port); // Ping the server and await a response + if (response == null) { // No response from ping + throw new ResourceNotFoundException("Server didn't respond to ping"); + } CachedMinecraftServer minecraftServer = new CachedMinecraftServer( - platform.name() + "-" + lookupHostname, - platform.getPinger().ping(hostname, port), - System.currentTimeMillis() + platform.name() + "-" + lookupHostname, response, System.currentTimeMillis() ); // Get the blocked status of the Java server diff --git a/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java b/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java index 3f376d2..76e284d 100644 --- a/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java +++ b/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java @@ -88,7 +88,11 @@ public final class JavaMinecraftServerPinger implements MinecraftServerPinger