Class MC

java.lang.Object
com.saicone.rtag.util.MC
All Implemented Interfaces:
Comparable<MC>

public final class MC extends Object implements Comparable<MC>
Utility class that provides general information of every supported Minecraft version.
  • Field Details

    • V_1_8

      public static final MC V_1_8
    • V_1_8_1

      public static final MC V_1_8_1
    • V_1_8_2

      public static final MC V_1_8_2
    • V_1_8_3

      public static final MC V_1_8_3
    • V_1_8_4

      public static final MC V_1_8_4
    • V_1_8_5

      public static final MC V_1_8_5
    • V_1_8_6

      public static final MC V_1_8_6
    • V_1_8_7

      public static final MC V_1_8_7
    • V_1_8_8

      public static final MC V_1_8_8
    • V_1_8_9

      public static final MC V_1_8_9
    • V_1_9

      public static final MC V_1_9
    • V_1_9_1

      public static final MC V_1_9_1
    • V_1_9_2

      public static final MC V_1_9_2
    • V_1_9_3

      public static final MC V_1_9_3
    • V_1_9_4

      public static final MC V_1_9_4
    • V_1_10

      public static final MC V_1_10
    • V_1_10_1

      public static final MC V_1_10_1
    • V_1_10_2

      public static final MC V_1_10_2
    • V_1_11

      public static final MC V_1_11
    • V_1_11_1

      public static final MC V_1_11_1
    • V_1_11_2

      public static final MC V_1_11_2
    • V_1_12

      public static final MC V_1_12
    • V_1_12_1

      public static final MC V_1_12_1
    • V_1_12_2

      public static final MC V_1_12_2
    • V_1_13

      public static final MC V_1_13
    • V_1_13_1

      public static final MC V_1_13_1
    • V_1_13_2

      public static final MC V_1_13_2
    • V_1_14

      public static final MC V_1_14
    • V_1_14_1

      public static final MC V_1_14_1
    • V_1_14_2

      public static final MC V_1_14_2
    • V_1_14_3

      public static final MC V_1_14_3
    • V_1_14_4

      public static final MC V_1_14_4
    • V_1_15

      public static final MC V_1_15
    • V_1_15_1

      public static final MC V_1_15_1
    • V_1_15_2

      public static final MC V_1_15_2
    • V_1_16

      public static final MC V_1_16
    • V_1_16_1

      public static final MC V_1_16_1
    • V_1_16_2

      public static final MC V_1_16_2
    • V_1_16_3

      public static final MC V_1_16_3
    • V_1_16_4

      public static final MC V_1_16_4
    • V_1_16_5

      public static final MC V_1_16_5
    • V_1_17

      public static final MC V_1_17
    • V_1_17_1

      public static final MC V_1_17_1
    • V_1_18

      public static final MC V_1_18
    • V_1_18_1

      public static final MC V_1_18_1
    • V_1_18_2

      public static final MC V_1_18_2
    • V_1_19

      public static final MC V_1_19
    • V_1_19_1

      public static final MC V_1_19_1
    • V_1_19_2

      public static final MC V_1_19_2
    • V_1_19_3

      public static final MC V_1_19_3
    • V_1_19_4

      public static final MC V_1_19_4
    • V_1_20

      public static final MC V_1_20
    • V_1_20_1

      public static final MC V_1_20_1
    • V_1_20_2

      public static final MC V_1_20_2
    • V_1_20_3

      public static final MC V_1_20_3
    • V_1_20_4

      public static final MC V_1_20_4
    • V_1_20_5

      public static final MC V_1_20_5
    • V_1_20_6

      public static final MC V_1_20_6
    • V_1_21

      public static final MC V_1_21
    • V_1_21_1

      public static final MC V_1_21_1
    • V_1_21_2

      public static final MC V_1_21_2
    • V_1_21_3

      public static final MC V_1_21_3
    • V_1_21_4

      public static final MC V_1_21_4
    • V_1_21_5

      public static final MC V_1_21_5
    • V_1_21_6

      public static final MC V_1_21_6
    • V_1_21_7

      public static final MC V_1_21_7
    • V_1_21_8

      public static final MC V_1_21_8
    • V_1_21_9

      public static final MC V_1_21_9
    • V_1_21_10

      public static final MC V_1_21_10
    • V_1_21_11

      public static final MC V_1_21_11
    • V_26_1

      public static final MC V_26_1
    • V_26_1_1

      public static final MC V_26_1_1
    • V_26_1_2

      public static final MC V_26_1_2
  • Method Details

    • version

      @NotNull public static @NotNull MC version()
      Get current server version.
      Returns:
      the version that server is running on.
    • first

      @NotNull public static @NotNull MC first()
      Get first supported version.
      Returns:
      the minimum supported version.
    • last

      @NotNull public static @NotNull MC last()
      Get last supported version.
      Returns:
      the maximum supported version.
    • 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

      @Experimental public float 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

      @Experimental public int 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

      @NotNull @Experimental public @NotNull String bukkitPackage()
      Get version as defined in craftbukkit package
      Returns:
      the craftbukkit package version string.
    • dataVersion

      @NotNull public @NotNull Optional<Integer> dataVersion()
      Get data version number as optional value.
      On versions before 1.9 this value will be empty.
      Returns:
      the data version number.
    • 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

      @NotNull public @NotNull Optional<Float> dataPackFormat()
      Get data pack format number as optional value.
      On versions before 1.12.1 this value will be empty.
      Returns:
      the data pack format number.
    • name

      Get the declaration version name as string (V_#_##).
      For a formatted name use toString().
      Returns:
      the version name.
    • ordinal

      @Internal public int 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

      public boolean isOlderThan(@NotNull @NotNull MC version)
      Check if this version is older than the given version.
      Parameters:
      version - the version to compare.
      Returns:
      true if this version is older.
    • isOlderThanOrEquals

      public boolean isOlderThanOrEquals(@NotNull @NotNull MC version)
      Check if this version is older than or equals to the given version.
      Parameters:
      version - the version to compare.
      Returns:
      true if this version is older or equals.
    • isNewerThan

      public boolean isNewerThan(@NotNull @NotNull MC version)
      Check if this version is newer than the given version.
      Parameters:
      version - the version to compare.
      Returns:
      true if this version is newer.
    • isNewerThanOrEquals

      public boolean isNewerThanOrEquals(@NotNull @NotNull MC version)
      Check if this version is newer than or equals to the given version.
      Parameters:
      version - the version to compare.
      Returns:
      true if this version is newer or equals.
    • isBetween

      public boolean isBetween(@NotNull @NotNull MC version1, @NotNull @NotNull MC version2)
      Check if this version is between the given versions (inclusive).
      Parameters:
      version1 - the first version to compare.
      version2 - the second version to compare.
      Returns:
      true if this version is between.
    • toString

      public String toString()
      Get the string representation of this version (#.##).
      Overrides:
      toString in class Object
      Returns:
      a formatted name.
    • fromString

      @Nullable @Internal public static @Nullable MC fromString(@NotNull @NotNull String s)
      Get version from string representation.
      Parameters:
      s - the string representation of the version.
      Returns:
      the MC version or null if not found.
    • fromAny

      @Nullable @Internal public static @Nullable MC fromAny(@Nullable @Nullable Object object)
      Get version from any object representation.
      Parameters:
      object - the object representation of the version.
      Returns:
      the MC version or null if not found.
    • 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

      public int compareTo(@NotNull @NotNull MC mc)
      Specified by:
      compareTo in interface Comparable<MC>
    • 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.