Package net.lucypoulton.squirtgun.update
Class UpdateChecker
java.lang.Object
net.lucypoulton.squirtgun.update.UpdateChecker
- Direct Known Subclasses:
PolymartUpdateChecker,VersionStringUpdateChecker
Update checking mechanism base class.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUpdateChecker(SquirtgunPlugin<?> plugin, String url, net.kyori.adventure.text.Component updateMessage, String listenerPermission)Creates a new update checker, and schedule update checking every 3 hours. -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected abstract booleancheckDataForUpdate(String input)Check if the result of a request indicates an update is available.booleanExecutes a blocking request to check for an update.protected SquirtgunPlugin<?>Gets the plugin that this checker is associated with.net.kyori.adventure.text.Component
-
Constructor Details
-
UpdateChecker
protected UpdateChecker(SquirtgunPlugin<?> plugin, String url, net.kyori.adventure.text.Component updateMessage, String listenerPermission)Creates a new update checker, and schedule update checking every 3 hours.- Parameters:
plugin- the plugin to check againsturl- a URL (such as the spigot api) that will return a plaintext version string when retrievedupdateMessage- the message to show in console and to players with the listener permission on joinlistenerPermission- if a player holds this permission and an update is available, they will be sent the update message in chat
-
-
Method Details
-
checkDataForUpdate
Check if the result of a request indicates an update is available.- Parameters:
input- the string result of a HTTP GET request from the URL provided to the constructor- Returns:
- whether the data provided shows an update available. In the event of an error, a warning should be printed to the console and this should return false.
-
getPlugin
Gets the plugin that this checker is associated with. -
checkForUpdate
public boolean checkForUpdate()Executes a blocking request to check for an update. In the event of failure, a warning will be printed to the console.- Returns:
- whether an update is available. Should the check fail, returns false
-
getUpdateMessage
public net.kyori.adventure.text.Component getUpdateMessage()- Returns:
- the update message as set in the constructor
-
checkDataForUpdate
public boolean checkDataForUpdate()- Returns:
- whether there is an update available. Note that this will not check for updates, only return a cached result.
-
getListenerPermission
- Returns:
- the listener permission as set in the constructor
-