Beispiel #1
0
  protected void config() {
    if (!file.exists()) {
      warning("Creating new configuration file for Bottom Line");
    }

    conf = YamlConfiguration.loadConfiguration(file);

    if (file.exists()) {
      saveDefaultConfig();

      if (Updater.compareVersions(vers, getConfig().getString("version")) == 1) {
        File configFolder = new File(this.getDataFolder() + File.separator + "archives");
        if (!configFolder.exists()) {
          configFolder.mkdirs();
        }

        File oldConfig =
            new File(configFolder.getPath(), "config " + getConfig().getString("version") + ".txt");

        try {
          if (oldConfig.getName().equals("config " + vers + ".txt")) {
            configFolder.delete();
            oldConfig.delete();
          } else {
            if (!configFolder.exists()) {
              configFolder.mkdirs();
            }
            oldConfig.createNewFile();

            warning("Crearted new configuration file, renamed old file to " + oldConfig.getName());
          }
        } catch (IOException e) {
          e.printStackTrace();
          error("Failed to create a copy of the old config file while generating new one!");
        }

        file.renameTo(oldConfig);
      }
    }

    saveDefaultConfig();
    d.setup(this);
    e.setup(this);
    j.setup(this);
    w.setup(this);
    s.setup(this);
    txt.setup(this);

    debug("Enabled configuration!");
  }