public void reload() { config.load(); for (Setting setting : Setting.values()) if (root.keyExists(setting.path)) setting.loadFromKey(root); save(); }
public void load() { config.load(); DataKey root = config.getKey(""); for (Setting setting : Setting.values()) if (!root.keyExists(setting.path)) root.setRaw(setting.path, setting.get()); else setting.set(root.getRaw(setting.path)); }
public Settings(File folder) { config = new YamlStorage(new File(folder, "config.yml"), "Citizens Configuration"); root = config.getKey(""); config.load(); for (Setting setting : Setting.values()) { if (!root.keyExists(setting.path)) { setting.setAtKey(root); } else setting.loadFromKey(root); } save(); }
public static void LoadDefaults() { try { Settings.globals.load( new File("plugins" + File.separator + "MonsterHunt" + File.separator, "global.txt")); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (InvalidConfigurationException e1) { e1.printStackTrace(); } for (String i : new String[] { "Zombie", "Skeleton", "Creeper", "Spider", "Ghast", "Slime", "ZombiePigman", "Giant", "TamedWolf", "WildWolf", "ElectrifiedCreeper", "Player", "Enderman", "Silverfish", "CaveSpider", "EnderDragon", "MagmaCube", "Blaze" }) { if (Settings.globals.get("Value." + i) != null) continue; Settings.globals.set("Value." + i + ".General", 10); Settings.globals.set("Value." + i + ".Wolf", 7); Settings.globals.set("Value." + i + ".Arrow", 4); Settings.globals.set("Value." + i + ".Snowball", 20); Settings.globals.set("Value." + i + ".283", 20); } for (String i : new String[] { "MushroomCow", "Chicken", "Cow", "Pig", "Sheep", "SnowGolem", "Squid", "Villager" }) { if (Settings.globals.get("Value." + i) != null) continue; Settings.globals.set("Value." + i + ".General", 0); } if (!new File("plugins" + File.separator + "MonsterHunt" + File.separator, "global.txt") .exists()) { Settings.globals.set("MinimumPointsPlace1", 1); Settings.globals.set("MinimumPointsPlace2", 1); Settings.globals.set("MinimumPointsPlace3", 1); Settings.globals.set("Rewards.RewardParametersPlace1", "3 3"); Settings.globals.set("Rewards.RewardParametersPlace2", "3 2"); Settings.globals.set("Rewards.RewardParametersPlace3", "3 1"); } for (Setting s : Setting.values()) { if (s.writeDefault() && Settings.globals.get(s.getString()) == null) Settings.globals.set(s.getString(), s.getDefault()); } try { Settings.globals.save( new File("plugins" + File.separator + "MonsterHunt" + File.separator, "global.txt")); } catch (IOException e) { e.printStackTrace(); } }