Class ProtocolVersion
java.lang.Object
com.viaversion.viaversion.api.protocol.version.ProtocolVersion
- All Implemented Interfaces:
Comparable<ProtocolVersion>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
Deprecated, for removal: This API element is subject to removal in a future version.static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
static final ProtocolVersion
-
Constructor Summary
ConstructorDescriptionProtocolVersion
(VersionType versionType, int version, int snapshotVersion, String name, @Nullable SubVersionRange versionRange) Constructs a new ProtocolVersion instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
betweenExclusive
(ProtocolVersion min, ProtocolVersion max) Returns whether this protocol version is between the given protocol versions, exclusive.boolean
betweenInclusive
(ProtocolVersion min, ProtocolVersion max) Returns whether this protocol version is between the given protocol versions, inclusive.int
compareTo
(ProtocolVersion other) protected @Nullable Comparator<ProtocolVersion>
Returns a custom comparator used to compare protocol versions.boolean
boolean
equalTo
(ProtocolVersion other) Returns whether this protocol version is equal to the other protocol version.static @Nullable ProtocolVersion
getClosest
(String protocol) Returns the registered protocol version if present, else null.int
Returns the snapshot protocol version with the snapshot indicator bit if this is a snapshot protocol version.Returns an immutable set of all included versions if the protocol is a version range.static int
getIndex
(ProtocolVersion version) Deprecated, for removal: This API element is subject to removal in a future version.comparison should be done via the comparison methodsgetName()
Returns the version name.int
Returns the release version if release, snapshot version (with the snapshot indicator bit) if snapshot.static @NonNull ProtocolVersion
getProtocol
(int version) static @NonNull ProtocolVersion
getProtocol
(VersionType versionType, int version) Returns a ProtocolVersion instance, even if this protocol version has not been registered.static List<ProtocolVersion>
Returns an immutable list of registered protocol versions.int
Returns the snapshot protocol version without the snapshot indicator bit if this is a snapshot protocol version.int
Returns the release protocol version.Returns the type of version (excluding whether it is a snapshot).int
hashCode()
boolean
isKnown()
Returns whether the protocol version isunknown
.boolean
isRange()
Returns whether the protocol includes a range of versions (but not an entire major version range), for example 1.7-1.7.5.static boolean
isRegistered
(int version) static boolean
isRegistered
(VersionType versionType, int version) Returns whether a protocol with the given protocol version is registered.boolean
Returns whether this represents a snapshot version.boolean
Returns whether the protocol includes an entire major version range (for example 1.8.x).boolean
newerThan
(ProtocolVersion other) Returns whether this protocol version is higher than the other protocol version.boolean
Returns whether this protocol version is higher than or equal to the other protocol version.boolean
olderThan
(ProtocolVersion other) Returns whether this protocol version is lower than the other protocol version.boolean
Returns whether this protocol version is lower than or equal to the other protocol version.static ProtocolVersion
static ProtocolVersion
static ProtocolVersion
register
(int version, String name, @Nullable SubVersionRange versionRange) static void
register
(ProtocolVersion protocolVersion) Registers a protocol version.toString()
-
Field Details
-
v1_7_2
-
v1_7_1
Deprecated, for removal: This API element is subject to removal in a future version. -
v1_7_6
-
v1_8
-
v1_9
-
v1_9_1
-
v1_9_2
-
v1_9_3
-
v1_10
-
v1_11
-
v1_11_1
-
v1_12
-
v1_12_1
-
v1_12_2
-
v1_13
-
v1_13_1
-
v1_13_2
-
v1_14
-
v1_14_1
-
v1_14_2
-
v1_14_3
-
v1_14_4
-
v1_15
-
v1_15_1
-
v1_15_2
-
v1_16
-
v1_16_1
-
v1_16_2
-
v1_16_3
-
v1_16_4
-
v1_17
-
v1_17_1
-
v1_18
-
v1_18_2
-
v1_19
-
v1_19_1
-
v1_19_3
-
v1_19_4
-
v1_20
-
v1_20_2
-
v1_20_3
-
v1_20_5
-
v1_21
-
v1_21_2
-
unknown
-
-
Constructor Details
-
ProtocolVersion
public ProtocolVersion(VersionType versionType, int version, int snapshotVersion, String name, @Nullable SubVersionRange versionRange) Constructs a new ProtocolVersion instance.- Parameters:
versionType
- protocol version typeversion
- protocol versionsnapshotVersion
- actual snapshot protocol version, -1 if not a snapshotname
- version nameversionRange
- range of versions that are supported by this protocol version, null if not a range
-
-
Method Details
-
register
-
register
-
register
public static ProtocolVersion register(int version, String name, @Nullable SubVersionRange versionRange) -
register
Registers a protocol version.- Parameters:
protocolVersion
- protocol version to register
-
isRegistered
Returns whether a protocol with the given protocol version is registered.- Parameters:
version
- protocol version- Returns:
- true if this protocol version has been registered
-
isRegistered
public static boolean isRegistered(int version) -
getProtocol
Returns a ProtocolVersion instance, even if this protocol version has not been registered. SeeisRegistered(VersionType, int)
beforehand orisKnown()
.- Parameters:
versionType
- protocol version typeversion
- protocol version- Returns:
- registered or unknown ProtocolVersion
-
getProtocol
-
getIndex
Deprecated, for removal: This API element is subject to removal in a future version.comparison should be done via the comparison methodsReturns the internal index of the stored protocol version.- Parameters:
version
- protocol version instance- Returns:
- internal index of the stored protocol version
-
getProtocols
Returns an immutable list of registered protocol versions.- Returns:
- immutable list of registered protocol versions
-
getClosest
Returns the registered protocol version if present, else null. This accepts the actual registered names (like "1.16.4/1.16.5") as well as included versions for version ranges and wildcards.- Parameters:
protocol
- version name, e.g. "1.16.3"- Returns:
- registered protocol version if present, else null
-
getVersionType
Returns the type of version (excluding whether it is a snapshot).- Returns:
- version type
- See Also:
-
getVersion
public int getVersion()Returns the release protocol version.- Returns:
- release version
-
getSnapshotVersion
public int getSnapshotVersion()Returns the snapshot protocol version without the snapshot indicator bit if this is a snapshot protocol version.- Returns:
- snapshot protocol version without the snapshot indicator bit
- Throws:
IllegalArgumentException
- if the version is not a snapshot version- See Also:
-
getFullSnapshotVersion
public int getFullSnapshotVersion()Returns the snapshot protocol version with the snapshot indicator bit if this is a snapshot protocol version.- Returns:
- snapshot protocol version with the snapshot indicator bit
- Throws:
IllegalArgumentException
- if the version is not a snapshot version- See Also:
-
getOriginalVersion
public int getOriginalVersion()Returns the release version if release, snapshot version (with the snapshot indicator bit) if snapshot.- Returns:
- release version if release, snapshot version (with the snapshot indicator bit) if snapshot
-
isKnown
public boolean isKnown()Returns whether the protocol version isunknown
. For checking if the protocol version is registered, useisRegistered(VersionType, int)
- Returns:
- true if the protocol version is unknown
-
isRange
public boolean isRange()Returns whether the protocol includes a range of versions (but not an entire major version range), for example 1.7-1.7.5.- Returns:
- true if the protocol includes a range of versions
- See Also:
-
getIncludedVersions
Returns an immutable set of all included versions if the protocol is a version range. If the protocol only includes a single Minecraft version or the entire major version as a wildcard (isVersionWildcard()
), the set will only contain the string given ingetName()
.- Returns:
- immutable set of all included versions if the protocol is a version range
- See Also:
-
isVersionWildcard
public boolean isVersionWildcard()Returns whether the protocol includes an entire major version range (for example 1.8.x).- Returns:
- true if the protocol includes an entire major version range
-
getName
Returns the version name.- Returns:
- version name
-
isSnapshot
public boolean isSnapshot()Returns whether this represents a snapshot version.- Returns:
- true if this represents a snapshot version, false otherwise
-
equalTo
Returns whether this protocol version is equal to the other protocol version.- Parameters:
other
- other protocol version- Returns:
- true if this protocol version is equal to the other protocol version
-
newerThan
Returns whether this protocol version is higher than the other protocol version.- Parameters:
other
- other protocol version- Returns:
- true if this protocol version is higher than the other protocol version
-
newerThanOrEqualTo
Returns whether this protocol version is higher than or equal to the other protocol version.- Parameters:
other
- other protocol version- Returns:
- true if this protocol version is higher than or equal to the other protocol version
-
olderThan
Returns whether this protocol version is lower than the other protocol version.- Parameters:
other
- other protocol version- Returns:
- true if this protocol version is lower than the other protocol version
-
olderThanOrEqualTo
Returns whether this protocol version is lower than or equal to the other protocol version.- Parameters:
other
- other protocol version- Returns:
- true if this protocol version is lower than or equal to the other protocol version
-
betweenInclusive
Returns whether this protocol version is between the given protocol versions, inclusive.- Parameters:
min
- minimum versionmax
- maximum version- Returns:
- true if this protocol version is between the given protocol versions, inclusive
-
betweenExclusive
Returns whether this protocol version is between the given protocol versions, exclusive.- Parameters:
min
- minimum versionmax
- maximum version- Returns:
- true if this protocol version is between the given protocol versions, exclusive
-
customComparator
Returns a custom comparator used to compare protocol versions. Must be overridden if the version type isVersionType.SPECIAL
- Returns:
- custom comparator
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ProtocolVersion>
-