Record Class MinecraftVersion

java.lang.Object
java.lang.Record
net.apartium.cocoabeans.structs.MinecraftVersion
Record Components:
major - major version
update - , update version
minor - minor version, if not explicitly specified defaults to 0
protocol - protocol version
All Implemented Interfaces:
Comparable<MinecraftVersion>

public record MinecraftVersion(int major, int update, int minor, int protocol) extends Record implements Comparable<MinecraftVersion>
Represents version in the game. Format: major.update.minor, ex 1.8.3
See Also:
  • Field Details

  • Constructor Details

    • MinecraftVersion

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

    • getVersion

      @AvailableSince("0.0.36") public static MinecraftVersion getVersion(int major, int update, int minor)
      Parameters:
      major - major version
      update - update version
      minor - minor version
      Returns:
      cached minecraft version or create a new one without any protocol version
    • getVersion

      @AvailableSince("0.0.36") public static MinecraftVersion getVersion(int major, int update, int minor, Supplier<Integer> protocol)
      Get Minecraft Version by lookup table or create new one
      Parameters:
      major - major version
      update - update version
      minor - minor version
      Returns:
      cached minecraft version or create a new one with desired protocol version
    • getByProtocolVersion

      @AvailableSince("0.0.51") public static List<MinecraftVersion> getByProtocolVersion(int protocol)
      Returns all minecraft versions corresponding to given protocol version
      Parameters:
      protocol - protocol version
      Returns:
      an immutable list of minecraft versions, or empty if none are found
    • isHigherThanOrEqual

      @AvailableSince("0.0.36") public boolean isHigherThanOrEqual(MinecraftVersion other)
      Helper method to check if current instance is higher than or equal to given version
      Parameters:
      other - other minecraft version
      Returns:
      true if higher than or equal, otherwise false
    • isHigherThan

      @AvailableSince("0.0.36") public boolean isHigherThan(MinecraftVersion other)
      Helper method to check if current instance is higher than given version
      Parameters:
      other - other minecraft version
      Returns:
      true if higher than or equal, otherwise false
    • isLowerThanOrEqual

      @AvailableSince("0.0.36") public boolean isLowerThanOrEqual(MinecraftVersion other)
      Helper method to check if current instance is lower than or equal to given version
      Parameters:
      other - other minecraft version
      Returns:
      true if lower than or equal, otherwise false
    • isLowerThan

      @AvailableSince("0.0.36") public boolean isLowerThan(MinecraftVersion other)
      Helper method to check if current instance is lower than given version
      Parameters:
      other - other minecraft version
      Returns:
      true if lower than, otherwise false
    • equals

      public boolean equals(Object other)
      Check if two versions are equal
      Specified by:
      equals in class Record
      Parameters:
      other - other minecraft version
      Returns:
      true if equal, otherwise false
    • hashCode

      public 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
    • isUnknown

      public boolean isUnknown()
      Detects whether current instance represents an unknown version
      Returns:
      true if unknown, else false
    • isProtocolKnown

      @AvailableSince("0.0.36") public boolean isProtocolKnown()
      Detects whether current instance represents a known version
      Returns:
      true if known, else false
    • compareTo

      @AvailableSince("0.0.46") public int compareTo(@NotNull @NotNull MinecraftVersion other)
      Specified by:
      compareTo in interface Comparable<MinecraftVersion>
    • toString

      public 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
    • major

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

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

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

      @AvailableSince("0.0.36") public int protocol()
      Returns the value of the protocol record component.
      Returns:
      the value of the protocol record component