From b26d5aa67fc4068ef9501826dcdda8fdbec966e6 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 10 Apr 2024 14:32:19 +0100 Subject: [PATCH] support 1.7 servers --- .../common/JavaMinecraftVersion.java | 15 +++++++++++++++ .../model/server/JavaMinecraftServer.java | 2 +- .../{mojang => token}/JavaServerStatusToken.java | 2 +- .../pinger/impl/JavaMinecraftServerPinger.java | 6 +++--- 4 files changed, 20 insertions(+), 5 deletions(-) rename src/main/java/cc.fascinated/model/{mojang => token}/JavaServerStatusToken.java (97%) diff --git a/src/main/java/cc.fascinated/common/JavaMinecraftVersion.java b/src/main/java/cc.fascinated/common/JavaMinecraftVersion.java index 62b1142..652e984 100644 --- a/src/main/java/cc.fascinated/common/JavaMinecraftVersion.java +++ b/src/main/java/cc.fascinated/common/JavaMinecraftVersion.java @@ -1,6 +1,7 @@ package cc.fascinated.common; import lombok.Getter; +import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.ToString; import lombok.extern.log4j.Log4j2; @@ -65,6 +66,8 @@ public enum JavaMinecraftVersion { V1_8(47, "v1_8_R3"), // 1.8.x + V1_7_6(5, "v1_7_R4"), // 1.7.6 - 1.7.10 + UNKNOWN(-1, "Unknown"); // Game Updates @@ -82,6 +85,8 @@ public enum JavaMinecraftVersion { public static final JavaMinecraftVersion THE_COMBAT_UPDATE = JavaMinecraftVersion.V1_9; public static final JavaMinecraftVersion BOUNTIFUL_UPDATE = JavaMinecraftVersion.V1_8; + private static final JavaMinecraftVersion[] VALUES = JavaMinecraftVersion.values(); + /** * The protocol number of this version. */ @@ -170,6 +175,16 @@ public enum JavaMinecraftVersion { return this.protocol <= other.getProtocol(); } + /** + * Get the minimum Minecraft version. + * + * @return the minimum version + */ + @NonNull + public static JavaMinecraftVersion getMinimumVersion() { + return VALUES[VALUES.length - 2]; + } + /** * Get the version from the given protocol. * diff --git a/src/main/java/cc.fascinated/model/server/JavaMinecraftServer.java b/src/main/java/cc.fascinated/model/server/JavaMinecraftServer.java index d0057cb..0a20a01 100644 --- a/src/main/java/cc.fascinated/model/server/JavaMinecraftServer.java +++ b/src/main/java/cc.fascinated/model/server/JavaMinecraftServer.java @@ -4,7 +4,7 @@ import cc.fascinated.Main; import cc.fascinated.common.JavaMinecraftVersion; import cc.fascinated.common.ServerUtils; import cc.fascinated.config.Config; -import cc.fascinated.model.mojang.JavaServerStatusToken; +import cc.fascinated.model.token.JavaServerStatusToken; import com.google.gson.annotations.SerializedName; import lombok.*; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/main/java/cc.fascinated/model/mojang/JavaServerStatusToken.java b/src/main/java/cc.fascinated/model/token/JavaServerStatusToken.java similarity index 97% rename from src/main/java/cc.fascinated/model/mojang/JavaServerStatusToken.java rename to src/main/java/cc.fascinated/model/token/JavaServerStatusToken.java index 57f7f22..ff0ddd0 100644 --- a/src/main/java/cc.fascinated/model/mojang/JavaServerStatusToken.java +++ b/src/main/java/cc.fascinated/model/token/JavaServerStatusToken.java @@ -1,4 +1,4 @@ -package cc.fascinated.model.mojang; +package cc.fascinated.model.token; import cc.fascinated.model.server.JavaMinecraftServer; import cc.fascinated.model.server.MinecraftServer; diff --git a/src/main/java/cc.fascinated/service/pinger/impl/JavaMinecraftServerPinger.java b/src/main/java/cc.fascinated/service/pinger/impl/JavaMinecraftServerPinger.java index fc2e3f0..81ea79b 100644 --- a/src/main/java/cc.fascinated/service/pinger/impl/JavaMinecraftServerPinger.java +++ b/src/main/java/cc.fascinated/service/pinger/impl/JavaMinecraftServerPinger.java @@ -2,12 +2,13 @@ package cc.fascinated.service.pinger.impl; import cc.fascinated.Main; import cc.fascinated.common.DNSUtils; +import cc.fascinated.common.JavaMinecraftVersion; import cc.fascinated.common.ServerUtils; import cc.fascinated.common.packet.impl.java.JavaPacketHandshakingInSetProtocol; import cc.fascinated.common.packet.impl.java.JavaPacketStatusInStart; import cc.fascinated.exception.impl.BadRequestException; import cc.fascinated.exception.impl.ResourceNotFoundException; -import cc.fascinated.model.mojang.JavaServerStatusToken; +import cc.fascinated.model.token.JavaServerStatusToken; import cc.fascinated.model.server.JavaMinecraftServer; import cc.fascinated.service.pinger.MinecraftServerPinger; import lombok.extern.log4j.Log4j2; @@ -42,12 +43,11 @@ public final class JavaMinecraftServerPinger implements MinecraftServerPinger