Class UpdateChecker

java.lang.Object
rocks.gravili.notquests.paper.managers.UpdateChecker

public final class UpdateChecker extends Object
A utility class to assist in checking for updates for plugins uploaded to SpigotMC. Before any members of this preferrably in its JavaPlugin.onEnable() method, though that is not a requirement.

This class performs asynchronous queries to Spigot's API. If the results of requestUpdateCheck() are inconsistent with what is published on SpigotMC, it may be due to the REST API cache. Results will be updated in due time.

  • Field Details

    • VERSION_SCHEME_DECIMAL

      public static final UpdateChecker.VersionScheme VERSION_SCHEME_DECIMAL
      The default version scheme for this update checker
  • Method Details

    • requestUpdateCheck

      @NotNull public CompletableFuture<UpdateChecker.UpdateResult> requestUpdateCheck()
      Request an update check to Spigot. This request is asynchronous and may not complete immediately as an HTTP GET request is published to the Spigot API.
      Returns:
      a future update result
    • getLastResult

      @Nullable public UpdateChecker.UpdateResult getLastResult()
      Get the last update result that was queried by requestUpdateCheck(). If no update check was performed since this class' initialization, this method will return null.
      Returns:
      the last update check result. null if none.
    • init

      @NotNull public static UpdateChecker init(@NotNull NotQuests main, int pluginID, @NotNull UpdateChecker.VersionScheme versionScheme)
      Initialize this update checker with the specified values and return its instance. If an instance of UpdateChecker has already been initialized, this method will act similarly to get() (which is recommended after initialization).
      Parameters:
      pluginID - the ID of the plugin as identified in the SpigotMC resource link. For example, "https://www.spigotmc.org/resources/veinminer.12038/" would expect "12038" as a value. The value must be greater than 0
      versionScheme - a custom version scheme parser. Cannot be null
      Returns:
      the UpdateChecker instance
    • init

      @NotNull public static UpdateChecker init(@NotNull NotQuests main, int pluginID)
      Initialize this update checker with the specified values and return its instance. If an instance of UpdateChecker has already been initialized, this method will act similarly to get() (which is recommended after initialization).
      Parameters:
      pluginID - the ID of the plugin as identified in the SpigotMC resource link. For example, "https://www.spigotmc.org/resources/veinminer.12038/" would expect "12038" as a value. The value must be greater than 0
      Returns:
      the UpdateChecker instance
    • get

      @NotNull public static UpdateChecker get()
      has not yet been invoked, this method will throw an exception.
      Returns:
      the UpdateChecker instance
    • isInitialized

      public static boolean isInitialized()
      Check whether the UpdateChecker has been initialized or not (if
      Returns:
      true if initialized, false otherwise