Class NmsVersionParser

java.lang.Object
com.kamikazejam.kamicommon.util.nms.NmsVersionParser

public class NmsVersionParser extends Object
  • Constructor Details

    • NmsVersionParser

      public NmsVersionParser()
  • Method Details

    • getFormattedNmsInteger

      public static int getFormattedNmsInteger(String mcVer)
      Converts a Minecraft version string into an integer that sorts in release order.

      Two eras, because Minecraft left 1.x versioning behind after 1.21.11 and moved to calendar versions (26.1.1, 26.1.2, 26.2, ...):

      • Legacy (1.x): the original packing is reproduced exactly, digit for digit, so every existing f("1.x.y") threshold keeps the value it has always had. Note the packing is textual rather than arithmetic, which is why 1.21.10 is 12110 and not 1220.
      • Calendar (>= 2.x): major*10_000 + minor*100 + patch, two digits each, so 26.2 reads as 26|02|00 and gives f("26.2") == 260200, f("26.1.2") == 260102. Every value lands far above every legacy value, since the legacy branch tops out at "1" + "99" + "99" == 19999, so no offset is needed and the two eras cannot overlap. It also stays monotonic, which the old 4-digit packing did not: that gave f("26.2") == 2620, sorting below f("1.21.11") == 12111.
      Parameters:
      mcVer - The MC version string (i.e. "1.20.4", "1.8.8", "26.2", or "26.2.build.115")
      Returns:
      The version as an order-preserving integer