Class UpdateChecker
java.lang.Object
rocks.gravili.notquests.paper.managers.UpdateChecker
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
A constant reason for the result ofUpdateChecker.UpdateResult
.final class
Represents a result for an update query performed byrequestUpdateCheck()
.static interface
A functional interface to compare two version Strings with similar version schemes. -
Field Summary
Modifier and TypeFieldDescriptionstatic final UpdateChecker.VersionScheme
The default version scheme for this update checker -
Method Summary
Modifier and TypeMethodDescriptionstatic UpdateChecker
get()
has not yet been invoked, this method will throw an exception.Get the last update result that was queried byrequestUpdateCheck()
.static UpdateChecker
Initialize this update checker with the specified values and return its instance.static UpdateChecker
init
(NotQuests main, int pluginID, UpdateChecker.VersionScheme versionScheme) Initialize this update checker with the specified values and return its instance.static boolean
Check whether the UpdateChecker has been initialized or not (ifRequest an update check to Spigot.
-
Field Details
-
VERSION_SCHEME_DECIMAL
The default version scheme for this update checker
-
-
Method Details
-
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
Get the last update result that was queried byrequestUpdateCheck()
. 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 toget()
(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 0versionScheme
- a custom version scheme parser. Cannot be null- Returns:
- the UpdateChecker instance
-
init
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 toget()
(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
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
-