Class ModrinthUpdateChecker
java.lang.Object
de.clickism.modrinthupdatechecker.ModrinthUpdateChecker
Utility class to check for newer versions of a project hosted on Modrinth.
-
Constructor Summary
ConstructorsConstructorDescriptionModrinthUpdateChecker(String projectId, String loader) Create a new update checker for the given project.ModrinthUpdateChecker(String projectId, String loader, @Nullable String minecraftVersion) Create a new update checker for the given project. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckVersion(Consumer<String> consumer) Check the latest version of the project for the given loader and minecraft version and call the consumer with it.protected @Nullable StringgetLatestVersion(com.google.gson.JsonArray versions) Get the latest compatible version from the versions array.static StringgetRawVersion(String version) Gets the raw version from a version string.protected booleanisVersionCompatible(com.google.gson.JsonObject version) Check if the version is compatible for the given loader and minecraft version.
-
Constructor Details
-
ModrinthUpdateChecker
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 IDloader- 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 IDloader- the loaderminecraftVersion- the minecraft version, or null for any version
-
-
Method Details
-
checkVersion
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
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
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
-