コード例 #1
0
 public void loadConfig() {
   try {
     config.createNewFile();
     reloadConfig();
   } catch (IOException e) {
     plugin.getLogger().log(Level.WARNING, "Cannot load configuration file.", e);
   }
 }
コード例 #2
0
 public void saveConfig() {
   try {
     Configuration conf = yaml.load(config);
     yaml.save(conf, config);
   } catch (IOException e) {
     plugin.getLogger().log(Level.WARNING, "Cannot save configuration file.", e);
   }
 }
コード例 #3
0
 public Configuration getRunningConfig() {
   try {
     Configuration conf = yaml.load(config);
     return conf;
   } catch (IOException e) {
     plugin.getLogger().log(Level.WARNING, "Cannot load configuration file.", e);
     e.printStackTrace();
   }
   return null;
 }
コード例 #4
0
  public void reloadConfig() {
    try {
      Configuration conf = yaml.load(config);

      if (conf.get("record-player-count") == null) {
        conf.set("record-player-count", 1);
        recordPlayerCount = 1;
      } else {
        recordPlayerCount = conf.getInt("record-player-count");
      }

      yaml.save(conf, config);
    } catch (IOException e) {
      plugin.getLogger().log(Level.WARNING, "Cannot load configuration file.", e);
    }
  }
コード例 #5
0
 public Config(RecordPlayerCounter plugin) {
   this.plugin = plugin;
   this.config = new File(plugin.getDataFolder(), "record.yml");
   this.config.getParentFile().mkdirs();
   this.yaml = ConfigurationProvider.getProvider(YamlConfiguration.class);
 }