From 69b72ef90d9b1aa8e6a773ecf18673f31958bd79 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sat, 17 Jun 2023 13:16:22 +0200 Subject: [PATCH] made ProtocolVersion comparable --- .../pandacube/lib/core/mc_version/ProtocolVersion.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java index d55bb4a..705c867 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java @@ -3,6 +3,7 @@ package fr.pandacube.lib.core.mc_version; import fr.pandacube.lib.core.json.Json; import fr.pandacube.lib.util.Log; import fr.pandacube.lib.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.io.InputStream; import java.io.InputStreamReader; @@ -13,7 +14,6 @@ import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.time.Duration; import java.util.List; -import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; /** @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicReference; * An instance of this class provides information related to a protocol version * (the protocol version number and all the corresponding Minecraft versions). */ -public class ProtocolVersion { +public class ProtocolVersion implements Comparable { private static final String ONLINE_DATA_URL = "https://api.pandacube.fr/rest/mcversion"; @@ -215,4 +215,9 @@ public class ProtocolVersion { public int hashCode() { return protocolVersionNumber; } + + @Override + public int compareTo(@NotNull ProtocolVersion o) { + return Integer.compare(protocolVersionNumber, o.protocolVersionNumber); + } }