Ejemplo n.º 1
0
  @Override
  public void onEnable() {
    currentVersion =
        Double.valueOf(getDescription().getVersion().split("-")[0].replaceFirst("\\.", ""));
    sm = getServer().getServicesManager();
    // Load Vault Addons
    loadEconomy();
    loadPermission();
    loadChat();

    getCommand("vault-info").setExecutor(this);
    getCommand("vault-reload").setExecutor(this);
    getCommand("vault-convert").setExecutor(this);
    getServer().getPluginManager().registerEvents(new VaultListener(), this);

    // Schedule to check the version every 30 minutes for an update. This is to update the most
    // recent
    // version so if an admin reconnects they will be warned about newer versions.
    this.getServer()
        .getScheduler()
        .scheduleAsyncRepeatingTask(
            this,
            new Runnable() {

              @Override
              public void run() {
                try {
                  newVersion = updateCheck(currentVersion);
                  if (newVersion > currentVersion) {
                    log.warning(
                        "Vault "
                            + newVersion
                            + " is out! You are running: Vault "
                            + currentVersion);
                    log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault");
                  }
                } catch (Exception e) {
                  // ignore exceptions
                }
              }
            },
            0,
            432000);

    // Load up the Plugin metrics
    try {
      String authors = "";
      for (String author : this.getDescription().getAuthors()) {
        authors += author + ", ";
      }
      if (!authors.isEmpty()) {
        authors = authors.substring(0, authors.length() - 2);
      }
      metrics = new Metrics(getDescription().getVersion(), authors);
      metrics.findCustomData(this);
      metrics.beginMeasuringPlugin(this);
    } catch (IOException e) {
      // ignore exception
    }
    log.info(
        String.format(
            "[%s] Enabled Version %s", getDescription().getName(), getDescription().getVersion()));
  }