Class ModrinthUpdateChecker

java.lang.Object
de.clickism.modrinthupdatechecker.ModrinthUpdateChecker

public class ModrinthUpdateChecker extends Object
Utility class to check for newer versions of a project hosted on Modrinth.
  • Constructor Details

    • ModrinthUpdateChecker

      public ModrinthUpdateChecker(String projectId, String loader)
      Create a new update checker for the given project. This will check the latest version for the given loader and any minecraft version.
      Parameters:
      projectId - the project ID
      loader - the loader
    • ModrinthUpdateChecker

      public ModrinthUpdateChecker(String projectId, String loader, @Nullable @Nullable String minecraftVersion)
      Create a new update checker for the given project. This will check the latest version for the given loader and minecraft version.
      Parameters:
      projectId - the project ID
      loader - the loader
      minecraftVersion - the minecraft version, or null for any version
  • Method Details

    • checkVersion

      public void checkVersion(Consumer<String> consumer)
      Check the latest version of the project for the given loader and minecraft version and call the consumer with it.
      Parameters:
      consumer - the consumer
    • getLatestVersion

      @Nullable protected @Nullable String getLatestVersion(com.google.gson.JsonArray versions)
      Get the latest compatible version from the versions array.
      Parameters:
      versions - the versions array
      Returns:
      the latest compatible version
    • isVersionCompatible

      protected boolean isVersionCompatible(com.google.gson.JsonObject version)
      Check if the version is compatible for the given loader and minecraft version.
      Parameters:
      version - the version
      Returns:
      true if the version is valid
    • getRawVersion

      public static String getRawVersion(String version)
      Gets the raw version from a version string. i.E: "fabric-1.2+1.17.1" -> "1.2"
      Parameters:
      version - the version string
      Returns:
      the raw version string