3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-03 08:41:05 +02:00

Add ProtocolVersion#betweenInclusive and ProtocolVersion#betweenExclusive (#3690)

Dieser Commit ist enthalten in:
EnZaXD 2024-02-13 21:50:19 +01:00 committet von GitHub
Ursprung 621c02f974
Commit e449599ae7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -210,7 +210,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
this.versionType = versionType;
this.version = version;
this.snapshotVersion = snapshotVersion;
this.name = name;;
this.name = name;
Preconditions.checkArgument(!(isVersionWildcard() && versionRange == null), "A wildcard name must have a version range");
if (versionRange != null) {
@ -377,6 +377,29 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
return this.compareTo(other) <= 0;
}
/**
* Returns whether this protocol version is between the given protocol versions, inclusive.
*
* @param min minimum version
* @param max maximum version
* @return true if this protocol version is between the given protocol versions, inclusive
*/
public boolean betweenInclusive(final ProtocolVersion min, final ProtocolVersion max) {
return this.higherThanOrEquals(min) && this.lowerThanOrEquals(max);
}
/**
* Returns whether this protocol version is between the given protocol versions, exclusive.
*
* @param min minimum version
* @param max maximum version
* @return true if this protocol version is between the given protocol versions, exclusive
*/
public boolean betweenExclusive(final ProtocolVersion min, final ProtocolVersion max) {
return this.higherThan(min) && this.lowerThan(max);
}
/**
* Returns a custom comparator used to compare protocol versions.
* Must be overridden if the version type is {@link VersionType#SPECIAL}