예제 #1
0
  /** Saves the defaults and missing values. */
  public void save() {
    if (!this.folder.exists()) {
      this.folder.mkdirs();
    }

    if (!this.file.exists()) {
      try {
        this.file.createNewFile();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    this.config = YamlConfiguration.loadConfiguration(this.file);
    for (Entry<String, Object> en : this.defaults.entrySet()) {
      if (!this.config.contains(en.getKey())) {
        ConfigUtils.setObject(this.config, en.getKey(), en.getValue());
      }
    }

    try {
      this.config.save(this.file);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
 /**
  * Gets a permission from the config.
  *
  * @param path
  * @return permission
  */
 public Permission getPermission(String path) {
   return ConfigUtils.getPermission(this.config.getConfigurationSection(path));
 }
예제 #3
0
 /**
  * Gets a random value from the config.
  *
  * @param path
  * @return randomValue
  */
 public RandomValue getRandom(String path) {
   return ConfigUtils.getRandom(this.config.getConfigurationSection(path));
 }