made ProtocolVersion comparable

This commit is contained in:
Marc Baloup 2023-06-17 13:16:22 +02:00
parent 555f5ab65c
commit 69b72ef90d

View File

@ -3,6 +3,7 @@ package fr.pandacube.lib.core.mc_version;
import fr.pandacube.lib.core.json.Json; import fr.pandacube.lib.core.json.Json;
import fr.pandacube.lib.util.Log; import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.util.StringUtil; import fr.pandacube.lib.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -13,7 +14,6 @@ import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers; import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration; import java.time.Duration;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference; 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 * An instance of this class provides information related to a protocol version
* (the protocol version number and all the corresponding Minecraft versions). * (the protocol version number and all the corresponding Minecraft versions).
*/ */
public class ProtocolVersion { public class ProtocolVersion implements Comparable<ProtocolVersion> {
private static final String ONLINE_DATA_URL = "https://api.pandacube.fr/rest/mcversion"; private static final String ONLINE_DATA_URL = "https://api.pandacube.fr/rest/mcversion";
@ -215,4 +215,9 @@ public class ProtocolVersion {
public int hashCode() { public int hashCode() {
return protocolVersionNumber; return protocolVersionNumber;
} }
@Override
public int compareTo(@NotNull ProtocolVersion o) {
return Integer.compare(protocolVersionNumber, o.protocolVersionNumber);
}
} }