Class MC
java.lang.Object
com.saicone.rtag.util.MC
- All Implemented Interfaces:
Comparable<MC>
Utility class that provides general information of every supported Minecraft version.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MCstatic final MC -
Method Summary
Modifier and TypeMethodDescriptionGet version as defined in craftbukkit packagestatic intCompare two MC versions.intGet data pack format number as optional value.
On versions before 1.12.1 this value will be empty.Get data version number as optional value.
On versions before 1.9 this value will be empty.floatGet craftbukkit package version as float value, for example:
v1_9_R2 -> 9.02
v1_13_R1 -> 13.01
v1_16_R3 -> 16.03intfeature()Get feature version number.Get version from a specific getter function and target value.Get version from a specific getter function and target value using a reverse lookup.first()Get first supported version.Get version from any object representation.Get version from string representation.intGet craftbukkit package version as int value, for example:
v1_9_R2 -> 10902
v1_13_R1 -> 11301
v1_19_R2 -> 11902booleanCheck if this version is between the given versions (inclusive).booleanCheck if version includes data component-based architecture (1.20.5 and above).booleanisFlat()Check if version is considered flat (1.13 and above).booleanisLegacy()Check if version is considered legacy (1.12.2 and below).booleanisNewerThan(@NotNull MC version) Check if this version is newer than the given version.booleanisNewerThanOrEquals(@NotNull MC version) Check if this version is newer than or equals to the given version.booleanisOlderThan(@NotNull MC version) Check if this version is older than the given version.booleanisOlderThanOrEquals(@NotNull MC version) Check if this version is older than or equals to the given version.booleanCheck if version is considered universal (1.17 and above).last()Get last supported version.intmajor()Get major version number.Get the maximum of two MC versions.Get the minimum of two MC versions.intminor()Get minor version number.name()intordinal()Get version ordinal number (internal value).intprotocol()Get protocol version number.floatGet resource pack format number.intrevision()Get version revision number.
Generally represents the "R" number in the craftbukkit package.toString()Get the string representation of this version (#.##).version()Get current server version.
-
Field Details
-
V_1_8
-
V_1_8_1
-
V_1_8_2
-
V_1_8_3
-
V_1_8_4
-
V_1_8_5
-
V_1_8_6
-
V_1_8_7
-
V_1_8_8
-
V_1_8_9
-
V_1_9
-
V_1_9_1
-
V_1_9_2
-
V_1_9_3
-
V_1_9_4
-
V_1_10
-
V_1_10_1
-
V_1_10_2
-
V_1_11
-
V_1_11_1
-
V_1_11_2
-
V_1_12
-
V_1_12_1
-
V_1_12_2
-
V_1_13
-
V_1_13_1
-
V_1_13_2
-
V_1_14
-
V_1_14_1
-
V_1_14_2
-
V_1_14_3
-
V_1_14_4
-
V_1_15
-
V_1_15_1
-
V_1_15_2
-
V_1_16
-
V_1_16_1
-
V_1_16_2
-
V_1_16_3
-
V_1_16_4
-
V_1_16_5
-
V_1_17
-
V_1_17_1
-
V_1_18
-
V_1_18_1
-
V_1_18_2
-
V_1_19
-
V_1_19_1
-
V_1_19_2
-
V_1_19_3
-
V_1_19_4
-
V_1_20
-
V_1_20_1
-
V_1_20_2
-
V_1_20_3
-
V_1_20_4
-
V_1_20_5
-
V_1_20_6
-
V_1_21
-
V_1_21_1
-
V_1_21_2
-
V_1_21_3
-
V_1_21_4
-
V_1_21_5
-
V_1_21_6
-
V_1_21_7
-
V_1_21_8
-
V_1_21_9
-
V_1_21_10
-
V_1_21_11
-
V_26_1
-
V_26_1_1
-
V_26_1_2
-
-
Method Details
-
version
-
first
-
last
-
major
public int major()Get major version number.- Returns:
- the major version number.
-
feature
public int feature()Get feature version number.- Returns:
- the feature version number.
-
minor
public int minor()Get minor version number.- Returns:
- the minor version number.
-
revision
public int revision()Get version revision number.
Generally represents the "R" number in the craftbukkit package.- Returns:
- the version revision number.
-
featRevision
Get craftbukkit package version as float value, for example:
v1_9_R2 -> 9.02
v1_13_R1 -> 13.01
v1_16_R3 -> 16.03- Returns:
- the craftbukkit package version as float value.
-
fullRevision
Get craftbukkit package version as int value, for example:
v1_9_R2 -> 10902
v1_13_R1 -> 11301
v1_19_R2 -> 11902- Returns:
- the craftbukkit package version as int value.
-
bukkitPackage
Get version as defined in craftbukkit package- Returns:
- the craftbukkit package version string.
-
dataVersion
-
protocol
public int protocol()Get protocol version number.- Returns:
- the protocol version number.
-
resourcePackFormat
public float resourcePackFormat()Get resource pack format number.- Returns:
- the resource pack format number.
-
dataPackFormat
-
name
- Returns:
- the version name.
-
ordinal
Get version ordinal number (internal value).- Returns:
- the version ordinal number.
-
isLegacy
public boolean isLegacy()Check if version is considered legacy (1.12.2 and below).- Returns:
- true if version is legacy.
-
isFlat
public boolean isFlat()Check if version is considered flat (1.13 and above).- Returns:
- true if version is flat.
-
isUniversal
public boolean isUniversal()Check if version is considered universal (1.17 and above).- Returns:
- true if version is universal.
-
isComponent
public boolean isComponent()Check if version includes data component-based architecture (1.20.5 and above).- Returns:
- true if version includes data component-based architecture.
-
isOlderThan
-
isOlderThanOrEquals
-
isNewerThan
-
isNewerThanOrEquals
-
isBetween
-
toString
-
fromString
-
fromAny
-
find
@Nullable @Internal public static <T> @Nullable MC find(@NotNull @NotNull Function<@NotNull MC, @Nullable T> getter, @Nullable T t) Get version from a specific getter function and target value.- Type Parameters:
T- the type of the target value.- Parameters:
getter- the function to get the value from each version.t- the target value to match.- Returns:
- the MC version or null if not found.
-
findReverse
@Nullable @Internal public static <T> @Nullable MC findReverse(@NotNull @NotNull Function<@NotNull MC, @Nullable T> getter, @Nullable T t) Get version from a specific getter function and target value using a reverse lookup.- Type Parameters:
T- the type of the target value.- Parameters:
getter- the function to get the value from each version.t- the target value to match.- Returns:
- the MC version or null if not found.
-
compareTo
-
compare
@Experimental public static int compare(@NotNull @NotNull MC version1, @NotNull @NotNull MC version2) Compare two MC versions.- Parameters:
version1- the first version to compare.version2- the second version to compare.- Returns:
- a negative integer, zero, or a positive integer as the first version is older than, equal to, or newer than the second.
-
max
@Nullable @Contract("null, !null -> param2; !null, null -> param1; null") @Experimental public static @Nullable MC max(@Nullable @Nullable MC version1, @Nullable @Nullable MC version2) Get the maximum of two MC versions.- Parameters:
version1- the first version to compare.version2- the second version to compare.- Returns:
- the maximum version, or null if both are null.
-
min
@Nullable @Contract("null, !null -> param2; !null, null -> param1") @Experimental public static @Nullable MC min(@Nullable @Nullable MC version1, @Nullable @Nullable MC version2) Get the minimum of two MC versions.- Parameters:
version1- the first version to compare.version2- the second version to compare.- Returns:
- the minimum version, or null if both are null.
-