Class AbstractGuizhanBuildsUpdater

java.lang.Object
net.guizhanss.guizhanlib.updater.AbstractGuizhanBuildsUpdater
Direct Known Subclasses:
GuizhanBuildsCNUpdater, GuizhanBuildsUpdater

public abstract class AbstractGuizhanBuildsUpdater extends Object
The Guizhan Builds Updater is responsible to auto-update the plugin from Guizhan Builds (builds.guizhanss.net).

This class can be extended for mirror URLs.

Author:
ybw0014
  • Constructor Details

    • AbstractGuizhanBuildsUpdater

      @ParametersAreNonnullByDefault public AbstractGuizhanBuildsUpdater(Plugin plugin, File file, String user, String repo, String branch, boolean checkOnly)
      This constructor sets up the updater.
      Parameters:
      plugin - The Plugin instance
      file - The File of plugin
      user - GitHub user
      repo - GitHub repository
      branch - GitHub branch
      checkOnly - Whether to check the version only, without downloading
    • AbstractGuizhanBuildsUpdater

      @Deprecated @ParametersAreNonnullByDefault public AbstractGuizhanBuildsUpdater(Plugin plugin, File file, String user, String repo, String branch, boolean checkOnly, String lang)
      Deprecated.
      The language option is no longer used, since it is now configured under global config file (/plugins/GuizhanBuildsUpdater/config.yml).
      This constructor sets up the updater.
      Parameters:
      plugin - The Plugin instance
      file - The File of plugin
      user - GitHub user
      repo - GitHub repository
      branch - GitHub branch
      checkOnly - Whether to check the version only, without downloading
      lang - The language of updater
  • Method Details

    • getBuildsURL

      @Nonnull public abstract String getBuildsURL()
      Override this method to specify the builds page's URL.

      No trailing slash is needed.

      Example: https://builds.guizhanss.net

      Returns:
      the URL of builds page
    • getLanguage

      @Nonnull public abstract String getLanguage()
      Override this method to set the language of updater.
      Returns:
      the language of updater
    • start

      public void start()
      Run updater task.
    • getReposFileURL

      @Nonnull public String getReposFileURL()
      Get the URL of repository list file (repos.json).
      Returns:
      the URL of repository list file
    • getRepoKey

      @Nonnull public String getRepoKey()
      Get the repository key in repos.json.
      Returns:
      the repository key
    • getBuildsInfo

      @Nonnull public String getBuildsInfo(@Nonnull String directory)
      Get the URL of builds information file (builds.json).
      Parameters:
      directory - Working directory
      Returns:
      the URL of builds information file
    • log

      public void log(Level level, String message, Object... args)
      Call the logger of plugin.
      Parameters:
      level - log Level
      message - the message
      args - the arguments
    • log

      public void log(Level level, Exception exception, String message, Object... args)
      Call the logger of plugin.
      Parameters:
      level - log Level
      exception - the Exception
      message - the message
      args - the arguments
    • getTargetUrl

      @ParametersAreNonnullByDefault @Nonnull public String getTargetUrl(String directory, String target)
      Get the URL of the build artifact.
      Parameters:
      directory - Working directory
      target - Target filename
      Returns:
      the URL of the build artifact
    • getLocalizedString

      @ParametersAreNonnullByDefault @Nonnull public String getLocalizedString(String key, String defaultValue)
      Get localized String.
      Parameters:
      key - The localization key
      defaultValue - The default value if localization is not found by key.
      Returns:
      The localized String.