Example #1
0
 public void save() {
   for (File file : dir.listFiles()) file.delete();
   YamlConfiguration yaml = new YamlConfiguration();
   for (Integer i : inventory.keySet()) {
     SerInventory.saveObj(inventory.get(i), new File(dir, i + ".ser").getAbsolutePath());
     yaml.set("inv" + i + ".min", minMap.get(i)[0]);
     yaml.set("inv" + i + ".max", minMap.get(i)[1]);
   }
   try {
     yaml.save(yamlFile);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Example #2
0
 public void reload() {
   inventory.clear();
   minMap.clear();
   YamlConfiguration yaml = YamlConfiguration.loadConfiguration(yamlFile);
   for (File file : dir.listFiles()) {
     if (file.getName().endsWith(".ser")) {
       Integer i = Integer.parseInt(file.getName().substring(0, file.getName().indexOf('.')));
       inventory.put(i, (SerInventory) SerInventory.loadObject(file.getAbsolutePath()));
       if (yaml.contains("inv" + i)) {
         minMap.put(
             i, new Integer[] {yaml.getInt("inv" + i + ".min"), yaml.getInt("inv" + i + ".max")});
       }
     }
   }
 }