Beispiel #1
0
  public void run(File pluginfile) {
    if (!ClassManager.manager.getSettings().getUpdaterEnabled()) {
      return;
    }

    BossShop plugin = ClassManager.manager.getPlugin();

    boolean auto_download_update =
        false; // ClassManager.manager.getSettings().getAutoDownloadUpdateEnabled();
    Updater updater =
        new Updater(
            plugin,
            65031,
            pluginfile,
            auto_download_update ? UpdateType.DEFAULT : UpdateType.NO_DOWNLOAD,
            true) {
          @Override
          public boolean shouldUpdate(String localVersion, String remoteVersion) {
            if (getWorth(remoteVersion) > getWorth(localVersion)) {
              Bukkit.getLogger()
                  .info(
                      "Found BossShop '"
                          + remoteVersion
                          + "'. You currently are using '"
                          + localVersion
                          + "'.");
              return true;
            }
            return false;
          }
        };
    update =
        updater.getResult()
            == Updater.UpdateResult
                .UPDATE_AVAILABLE; // Determine if there is an update ready for us
    name = updater.getLatestName(); // Get the latest name
    version = updater.getLatestGameVersion(); // Get the latest game version
    type = updater.getLatestType(); // Get the latest file's ty
    if (update == true) {
      ClassManager.manager
          .getBugFinder()
          .warn("Update was found: " + name + ". You can download it here: " + link + ".");
      ClassManager.manager.setUpdaterManager(this);
      if (plugin.getPlayerJoinListener() != null) {
        plugin.getPlayerJoinListener().setEnabled(true);
      }
    }
  }
  /** Run the updater. */
  @Override
  public void run() {

    Updater.UpdateType type;

    switch (updaterType.toLowerCase()) {
      case "download":
        type = Updater.UpdateType.DEFAULT;
        break;
      case "check":
        type = Updater.UpdateType.NO_DOWNLOAD;
        break;
      case "force":
        type = Updater.UpdateType.NO_VERSION_CHECK;
        break;
      default:
        type = Updater.UpdateType.DEFAULT;
    }

    Updater updater = new Updater(plugin, ID, file, type, true);

    Updater.UpdateResult result = updater.getResult();

    switch (result) {
      case SUCCESS:
        plugin
            .getLogger()
            .log(
                Level.INFO,
                "A new update has been downloaded. Please restart the server for the changes to take effect.");
        break;
      case NO_UPDATE:
        plugin.getLogger().log(Level.INFO, "No update was found.");
        break;
      case DISABLED:
        plugin.getLogger().log(Level.INFO, "Updater did not run, it is globally disabled.");
        break;
      case FAIL_DOWNLOAD:
        plugin.getLogger().log(Level.WARNING, "An update was found, but failed to download.");
        break;
      case FAIL_DBO:
        plugin
            .getLogger()
            .log(
                Level.WARNING,
                "Updater was unable to connect with dev.bukkit.org to look for updates.");
        break;
      case FAIL_NOVERSION:
        plugin
            .getLogger()
            .log(
                Level.WARNING,
                "Invalid version name on dev.bukkit.org - please contact the author.");
        break;
      case FAIL_BADID:
        plugin.getLogger().log(Level.WARNING, "The project ID was invalid or could not be found.");
        break;
      case FAIL_APIKEY:
        plugin.getLogger().log(Level.WARNING, "Invalid API key.");
        break;
      case UPDATE_AVAILABLE:
        plugin
            .getLogger()
            .log(
                Level.INFO,
                "A new update has been found. Please visit \""
                    + updater.getLatestFileLink()
                    + "\" to download it.");
        updateAvailable = true;
        break;
      default:
        plugin.getLogger().log(Level.WARNING, "An unexpected result was received from Updater.");
    }
  }