Class UpdateChecker

java.lang.Object
net.lucypoulton.squirtgun.update.UpdateChecker
Direct Known Subclasses:
PolymartUpdateChecker, SpigotUpdateChecker

public abstract class UpdateChecker extends Object
Update checking mechanism base class.
  • 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 against
      url - a URL (such as the spigot api) that will return a plaintext version string when retrieved
      updateMessage - the message to show in console and to players with the listener permission on join
      listenerPermission - if a player holds this permission and an update is available, they will be sent the update message in chat
  • Method Details

    • checkDataForUpdate

      protected abstract boolean checkDataForUpdate(String input)
      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

      protected SquirtgunPlugin<?> 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

      public String getListenerPermission()
      Returns:
      the listener permission as set in the constructor