Record Class MinecraftVersion

java.lang.Object
java.lang.Record
com.plotsquared.core.util.MinecraftVersion
Record Components:
major - the major part of the version string. For versions pre 26 this is the minor version part
minor - the minor part of the version string. For versions pre 26 this is the patch version part
patch - the patch part of the version string. For versions pre 26 this is always 0
All Implemented Interfaces:
Comparable<MinecraftVersion>

public record MinecraftVersion(int major, int minor, int patch) extends Record implements Comparable<MinecraftVersion>
Represents a Minecraft version. For simplicity, and compatibility with modern versions, the `1.` prefix of older versions is ignored and the minor version part becomes the major version part.

  • `1.17.0` -> `(17, 0, 0)`
  • `26.2` -> `(26, 2, 0)`
  • `26.1.2` -> `(26, 1, 2)`
  • Field Details

  • Constructor Details

    • MinecraftVersion

      public MinecraftVersion(int major, int minor, int patch)
      Creates an instance of a MinecraftVersion record class.
      Parameters:
      major - the value for the major record component
      minor - the value for the minor record component
      patch - the value for the patch record component
  • Method Details

    • current

      public static MinecraftVersion current()
    • compareTo

      public int compareTo(@NotNull @NotNull MinecraftVersion o)
      Specified by:
      compareTo in interface Comparable<MinecraftVersion>
    • isNewerOrEqualThan

      public boolean isNewerOrEqualThan(MinecraftVersion other)
    • isOlderOrEqualThan

      public boolean isOlderOrEqualThan(MinecraftVersion other)
    • isOlderThan

      public boolean isOlderThan(MinecraftVersion other)
    • isNewerOrEqualThan

      public boolean isNewerOrEqualThan(int otherMajor)
    • isNewerOrEqualThan

      public boolean isNewerOrEqualThan(int otherMajor, int otherMinor)
    • isOlderOrEqualThan

      public boolean isOlderOrEqualThan(int otherMajor)
    • isOlderOrEqualThan

      public boolean isOlderOrEqualThan(int otherMajor, int otherMinor)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • major

      public int major()
      Returns the value of the major record component.
      Returns:
      the value of the major record component
    • minor

      public int minor()
      Returns the value of the minor record component.
      Returns:
      the value of the minor record component
    • patch

      public int patch()
      Returns the value of the patch record component.
      Returns:
      the value of the patch record component