Class VersionUtils

java.lang.Object
de.studiocode.inventoryaccess.util.VersionUtils

public class VersionUtils extends Object
  • Constructor Details

    • VersionUtils

      public VersionUtils()
  • Method Details

    • toMajorMinorPatch

      public static int[] toMajorMinorPatch(String version)
      Converts a version string like "1.17.1" or "1.17" to an array of three ints.
      Parameters:
      version - The version to check against
      Returns:
      The version as an array of three ints.
      Throws:
      NumberFormatException - If an invalid version string is provided.
    • isHigherOrEqualThanServer

      public static boolean isHigherOrEqualThanServer(String version)
      Returns if the given version is higher or equal to the one currently running on the server.
      Parameters:
      version - The version to check against
      Returns:
      If the given version is running on this server or a newer one.
    • isHigherOrEqualThanServer

      public static boolean isHigherOrEqualThanServer(int... version)
      Returns if the given version is higher or equal to the one currently running on the server.
      Parameters:
      version - The version to check against
      Returns:
      If the given version is running on this server or a newer one.
      Throws:
      IllegalArgumentException - If the version array does not have a size of 3
    • isServerHigherOrEqual

      public static boolean isServerHigherOrEqual(String version)
      Returns if the server is on this or a newer version of Minecraft.
      Parameters:
      version - The version to check against
      Returns:
      If the server is running this exact or a newer version of Minecraft.
    • isServerHigherOrEqual

      public static boolean isServerHigherOrEqual(int... version)
      Returns if the server is on this or a newer version of Minecraft.
      Parameters:
      version - The version to check against
      Returns:
      If the server is running this exact or a newer version of Minecraft.
      Throws:
      IllegalArgumentException - If the version array does not have a size of 3