Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Add ProtocolVersion#betweenInclusive and ProtocolVersion#betweenExclusive (#3690)
Dieser Commit ist enthalten in:
Ursprung
621c02f974
Commit
e449599ae7
@ -210,7 +210,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
|
|||||||
this.versionType = versionType;
|
this.versionType = versionType;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.snapshotVersion = snapshotVersion;
|
this.snapshotVersion = snapshotVersion;
|
||||||
this.name = name;;
|
this.name = name;
|
||||||
|
|
||||||
Preconditions.checkArgument(!(isVersionWildcard() && versionRange == null), "A wildcard name must have a version range");
|
Preconditions.checkArgument(!(isVersionWildcard() && versionRange == null), "A wildcard name must have a version range");
|
||||||
if (versionRange != null) {
|
if (versionRange != null) {
|
||||||
@ -377,6 +377,29 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
|
|||||||
return this.compareTo(other) <= 0;
|
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.
|
* Returns a custom comparator used to compare protocol versions.
|
||||||
* Must be overridden if the version type is {@link VersionType#SPECIAL}
|
* Must be overridden if the version type is {@link VersionType#SPECIAL}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren