Version Checker/1.17

From Forge Community Wiki
Revision as of 05:52, 6 December 2021 by ShrimpBot (talk | contribs) (Copy Version Checker to MC1.17 archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Version Checker is a Forge-provided utility for mods to check for new versions based on an online update JSON file. It is lightweight, toggleable, asynchoronous to the main mod loading, and integrates cleanly with the mods list menu.

If there are outdated mods according to the version checker, a flashing emerald indicator will be shown on the Mods button on the main menu. The entries for the outdated mods in the mods list screen have the flashing emerald indicator. The information screen for outdated mods will have an Update available: line with the homepage URL from the update JSON file, and a list of mod versions and corresponding text after the mod description, for the mod versions between the most up-to-date and the currently installed version.

The version checker can be configured through the versionCheck option in the FML config (config/fml.toml). This option controls the version checking for all mods, including Forge.

Update JSON format

The version checker checks the update JSON, specified by the updateJSONURL for the mod in the mods.toml. An example of a JSON file is the update JSON for Minecraft Forge. The JSON file must be in the following format:

  • Root object
    • homepage (string): A URL, displayed on the mod's information screen on the Mods list screen
    • promos (object)
      • <minecraft version>-latest (string): A version string, for the latest mod version corresponding to the given Minecraft version
      • <minecraft version>-recommended (string): A version string, for the recommended mod version corresponding to the given Minecraft version
      • ...
    • <minecraft version> (object)
      • <mod version> (string): Any text, displayed when the the specified mod version in the key is ahead of currently installed version; used as a changelog
      • ...

Update status

There are 7 possible version checker statuses, according to the VersionChecker.Status enum:

  • PENDING - The version checker has not or is currently retrieving the version from the update JSON. This is temporary, and will change into one of the other statuses.
  • FAILED - The version checker failed, either to retrieve the update JSON or some other error (such as failure to parse broken JSON).
  • UP_TO_CODE - The currently installed version is the same as the recommended version for the current Minecraft version.
  • OUTDATED - The currently installed version is either behind the recommended version for the MC version, or ahead of the recommended version, but behind the latest version for the MC version.
  • AHEAD - The currently installed version is ahead of the recommended version for the MC version, and there is no more up-to-date latest version for the MC version.
  • BETA - There is no recommended version, and either the currently installed version is up-to-date or ahead of the latest version, or there is no latest version for the MC version.
  • BETA_OUTDATED - There is no recommended version, and the currently installed version is behind the latest version for the MC version.

CheckResult

The version checker result for a mod can be retrieving using the VersionChecker.getResult(IModInfo) static method which returns a CheckResult. (IModInfo is the information for a specific mod; see ModList#getModContainerById(String) and ModContainer#getModInfo()).

The CheckResult contains four unmodifiable fields:

  • status, the version checker status as a VersionChecker.Status enum value.
  • target, the version which caused the OUTDATED, BETA or BETA_OUTDATED
    • If the status is OUTDATED, this is the newest recommended or latest version from the JSON.
    • If the status is BETA_OUTDATED or BETA, this is the highest newest version from the JSON.
    • This may be null if the status is BETA, and there is no recommended or latest version defined in the JSON file.
  • changes, an unmodifiable map of mod versions and their corresponding text based on the MC version, where the mod versions are higher than the currently installed version. This information is shown on the mods information screen, as a changelog.
  • url, the URL from the homepage string in the update JSON, displayed on the mods information screen.